Influence of Storage
Type .
Latest notes: In case of text files, the number of bytes read depends on
the character format specified using
ENCODING when opening the file.
Example ABAP Coding This program section has the same functions as the
previous example. Here data is imported not into a byte-like field
symbol, but into a byte-like data object hex_container . The
number of bytes to be imported is determined by the typed field symbol
spfli .
DATA: file TYPE string VALUE `flights.dat`,
hex_container TYPE x LENGTH 1000,
len TYPE i,
itab TYPE TABLE OF spfli.
FIELD-SYMBOLS <(><<)>spfli> TYPE spfli.
DESCRIBE FIELD <(><<)>spfli> LENGTH len IN BYTE MODE.
OPEN DATASET file FOR INPUT IN BINARY MODE.
ASSIGN hex_container TO <(><<)>spfli> CASTING.
DO.
READ DATASET file INTO hex_container MAXIMUM LENGTH len.
IF sy-subrc = 0.
APPEND <(><<)>spfli> TO itab.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET file.
cl_demo_output=>display_data( itab ).
ABAP_ADDITION_2 ... [ACTUAL] LENGTH alen
What does it do? This addition assigns the number of characters or bytes
to be read from the file to the data object alen . The following
can be specified for alen :
An existing variable of the data type i or a variable to which
the type i can be converted.
An inline declaration DATA(var) , where
a variable of type i is declared.
For text files, the system determines how many characters were written
to the memory area. For binary files, legacy text files, and legacy
binary files, the system determines how many bytes were read from the
file.
Latest notes: Regardless of the length of the target field, the number
of characters or bytes actually read from the file is always returned.
The optional addition ACTUAL was introduced in order to be
better able to distinguish the addition LENGTH from the addition
MAXIMUM LENGTH . For this reason, the addition ACTUAL
should always be used.
Runtime Exceptions
Catchable Exceptions
CX_SY_CODEPAGE_CONVERTER_INIT
Reason for error: The desired conversion is not supported. (For example,
because a language not supported by the conversion was specified using
SET LOCALE LANGUAGE .)
Runtime error: CONVT_CODEPAGE_INIT
CX_SY_CONVERSION_CODEPAGE
Reason for error: Conversion is not possible. The data is read as far as
possible. Text data where the conversion has failed is undefined (see
also note below).
Runtime error: CONVT_CODEPAGE
CX_SY_FILE_AUTHORITY
Reason for error: No authorization for access to file
Runtime error: OPEN_DATASET_NO_AUTHORITY
CX_SY_FILE_IO
Reason for error: When reading the file, an error occurred.
Runtime error: DATASET_READ_ERROR
CX_SY_FILE_OPEN
Reason for error: File cannot be opened.
Runtime error: DATASET_CANT_OPEN
CX_SY_FILE_OPEN_MODE
Reason for error: The file is not open.
Runtime error: DATASET_NOT_OPEN
CX_SY_PIPE_REOPEN
Reason for error: The file was opened using the addition FILTER and
since then a switch of the work process took place.
Runtime error: DATASET_PIPE_CLOSED
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved