Get Example source ABAP code based on a different SAP table
• CODE PAGE OPEN DATASET
OPEN DATASET>, CODE PAGE> Short Reference >
ABAP_SYNTAX ... CODE PAGE cp ...>
What does it do? This addition specifies that, when a legacy file> is opened, the representation of character-like data objects in the file is based on the code page specified in cp>. When a character-like data object is written or read, a conversion between this code page and the current character representation is performed, if necessary. If this addition is not specified, the characters in the file are handled in accordance with the non-Unicode code page that would be assigned when reading or writing data in a non-Unicode system (as specified by the entry in the database table TCP0C>> in the current text environment>). To specify the code page cp> a character-like data object is expected that must contain, when the statement is executed, the name of a non-Unicode page from the column CPCODEPAGE> in the database table TCP00>>. Unicode code pages cannot be specified.
Latest notes:
This addition enables the automatic conversion of file content to the current Unicode character representation UCS-2> when reading and writing files. In this way, files that were stored in any non-Unicode systems can be imported.
The statement SET DATASET>> can be used to specify a different code page for an opened legacy file.
The addition CODE PAGE> replaces the use of the obsolete statement TRANSLATE CODE PAGE>> in when accessing files. ABAP_HINT_END
Example ABAP Coding
Opens legacy text files with the IDs 1101> for 7-Bit USA ASCII and 1102> for 7-Bit German ASCII from the table TCP00>>. When an attempt is made to write a German umlaut character to the open file with the ID 1101>, an exception of the class CX_SY_CONVERSION_CODEPAGE> is raised. When the character is written to the open file with the ID 1102>, this exception is not raised. See also the example for the addition REPLACEMENT CHARACTER >>. ABEXA 00464 ABAP_EXAMPLE_END