ABAPGET_DATASET - GET DATASET

Vendor Master (General Section)   Fill RESBD Structure from EBP Component Structure  
This documentation is copyright by SAP AG.

GET DATASET

Short Reference



Syntax

GET DATASET dset [POSITION pos] [ATTRIBUTES attr].

Additions

1. ... POSITION pos

2. ... ATTRIBUTES attr

Effect

With the POSITION addition, this statement determines the current position of the file pointer in the file specified in dset and gets additional file attributes using the ATTRIBUTES addition.

dset must be a character-like data object that contains theplatform-specific name of the file. The file must be open, otherwise an exception that can be handled is raised.

Note

If no additions are specified, the statement can be used to determine whether or not the file is openwith the aid of a TRY control structure.

Addition 1

... POSITION pos

Effect

This addition assigns the current position of the file pointer to the data object pos, which must be a numeric variable. The position is specified in bytes; the start of the file corresponds to position 0.

The POSITION addition cannot be specified for files that were opened using the FILTERaddition to the OPEN DATASET statement, otherwise an exception that can be handled is raised.

Note

In the case of files larger than 2 GB, a data object pos of the data type i is not sufficient for including all possible positions of the file pointer.

Example

After the first literal is saved, the position of the file pointer is assigned to the variable pos, which is then used to position the file pointer before the read access.

DATA: file TYPE string VALUE 'test.dat',
      pos TYPE I,
      text TYPE string.

OPEN DATASET file FOR OUTPUT IN TEXT MODE
                            ENCODING DEFAULT
                             WITH SMART LINEFEED.
TRANSFER '1234567890' TO file.
GET DATASET file POSITION pos.
TRANSFER 'ABCDEFGHIJ' TO file.
CLOSE DATASET file.

OPEN DATASET file FOR INPUT IN TEXT MODE
                           ENCODING DEFAULT
                            WITH SMART LINEFEED
                            AT POSITION pos.
READ DATASET file INTO text.
CLOSE DATASET file.

Addition 2

... ATTRIBUTES attr

Effect

This addition places the attributes with which the file was opened (using the OPEN DATASET statement) into the data object attr. The data type of attr must be dset_attributes, which is defined in thetype group DSET as follows:

dset_attributes is a structured type with two substructures: fixed and changeable.The components of the substructure fixed take in attributes of the file that cannot be changedusing the SET DATASET statement (see Table1). The components of the substructure changeable include attributes of the file that can be changed using the SET DATASET statement (see Table2).

Table 1

ComponentDescription
indicatorStructure, whose components mode, access_type, encoding, andfilter contain the value "X" in attr if the identically-named components of the structure fixed are significant for the current file.
modeStorage type. Possible values in attr are "T", "LT", "B", and "LB" fortext files,legacy text files,binary files, andlegacybinary files. The corresponding addition to the OPEN DATASET statement is IN mode.
access_typeAccess type. Possible values in attr are "I", "O", "A", and "U" for filesthat were opened for reading, writing, appending, and editing. The corresponding addition to the OPENDATASET statement is FOR access.
encodingCharacter representation. Possible values in attr are "NON-UNICODE" and "UTF-8".The corresponding addition to the OPEN DATASET statement is ENCODING { DEFAULT | UTF-8 | NON-UNICODE }.
filterIn attr, contains the filter command if the file was opened with the FILTER addition to the OPEN DATASET statement.
linefeedContains the end-of-line marking used during access in the case of atext file orlegacy text file.

Table 2

ComponentDescription
indicatorStructure, whose components repl_char, conv_errors, code_page,and endian contain the value "X" in attr if the identically-named components of the structure changeable are significant for the current file.
repl_charAfter opening the file, this component contains the replacement character in attrthat was specified using the REPLACEMENT CHARACTER addition to the OPEN DATASET statement.
conv_errorsAfter opening the file, this component contains the value "I" in attr if itwas opened using the addition IGNORINGCONVERSION ERRORS of the statement OPEN DATASET, otherwise it contains the value "R".
code_pageAfter opening the file, this component contains thecodepage in attr that was specified using the CODEPAGE addition to the OPEN DATASET statement. If this statement is not used, the content of attr initial.
endianAfter opening the file, this component contains the value "B" in attr if theBIG ENDIANaddition to the OPEN DATASET statement was used or "L" if the LITTLEENDIAN addition was used. If no addition is used, the content of attr is initial.
linefeed_modeContains in attr - after the file has been opened - one of the values "N","S", "U", or "W" if the respective addition WITHNATIVE|SMART|UNIX|WINDOWS LINEFEED of the statement OPEN DATASET was used. If none of the additions is used, the content in attr is initial.

For some of the components, constants are defined in the type group DSET as comparison values.

Note

The determinable attributes do not represent the attributes of the file in the operating system, but the attributes with and by which the file is opened and handled in ABAP.

Example

In this example, the system first checks whether the file test.dat was opened using the FILTER addition. Only if this is not the case, is the current file position determined using GET DATASET.

DATA: dset TYPE string VALUE 'test.dat',
      attr TYPE dset_attributes,
      pos  TYPE i.

OPEN DATASET dset FOR INPUT IN BINARY MODE
                  FILTER 'uncompress'.

...

GET DATASET dset ATTRIBUTES attr.
IF attr-fixed-indicator-filter <> 'X'.
  GET DATASET dset POSITION pos.
ELSE.
  ...
ENDIF.

CLOSE DATASET dset.

Exceptions






CPI1466 during Backup   General Data in Customer Master  
This documentation is copyright by SAP AG.


Length: 12949 Date: 20120522 Time: 062828     triton ( 289 ms )