Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Processing External Data →  ABAP File Interface →  Statements for the ABAP File Interface →  OPEN DATASET →  OPEN DATASET - mode 

OPEN DATASET - endian

Quick Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


... {BIG|LITTLE} ENDIAN ... 

Effect

This addition specifies that, when a legacy file is opened, numeric data objects of the type i, int8, decfloat16, decfloat34, f, or s are stored in the file in the byte order Big Endian or Little Endian. When a data object of these types is written or read, a conversion between these orders and the byte order of the current platform is performed, if necessary. If the addition is not specified, the byte order of the host computer of the current AS Instance is used.


Notes

  • The statement SET DATASET can be used to specify a different byte order for an opened legacy file.
  • The addition {BIG|LITTLE} ENDIAN replaces the use of the obsolete statement TRANSLATE NUMBER FORMAT in the case of file accesses.

Example

Opens a legacy binary file with different byte orders for writing. In each case, the integer 111 is written to the file and the content is read in binary format to a byte string. The results are 0000006F and 6F000000, that is, 111 in binary format in Big Endian and Little Endian.

DATA(dset) = 'test.dat'. 
DATA xstr TYPE xstring. 

OPEN DATASET dset FOR OUTPUT IN LEGACY BINARY MODE BIG ENDIAN. 
TRANSFER 111 TO dset. 
CLOSE DATASET dset. 
OPEN DATASET dset FOR INPUT IN BINARY MODE. 
READ DATASET dset INTO xstr. 
CLOSE DATASET dset. 
cl_demo_output=>write( xstr ). 

OPEN DATASET dset FOR OUTPUT IN LEGACY BINARY MODE LITTLE ENDIAN. 
TRANSFER 111 TO dset. 
CLOSE DATASET dset. 
OPEN DATASET dset FOR INPUT IN BINARY MODE. 
READ DATASET dset INTO xstr. 
CLOSE DATASET dset. 
cl_demo_output=>write( xstr ). 

cl_demo_output=>display( ). 

DELETE DATASET dset.