sapdev logo background
sapdev logo sapdev logo
Comments

ABAP OPEN DATASET ENCODING Statement syntax, information and example SAP source code



Return to Statement index



OPEN DATASET - encoding

Short Reference

ABAP Syntax ... ENCODING { DEFAULT
| {UTF-8 [SKIPPING|WITH BYTE-ORDER MARK]}
| NON-UNICODE } ... .

ABAP_ALTERNATIVES:
1 ... DEFAULT
2 ... UTF-8 [SKIPPING|WITH BYTE-ORDER MARK]
3 ... NON-UNICODE

What does it do? The additions after ENCODING define the character representation in which the content of a text file is handled. The addition ENCODING must be specified in Unicode programs and may only be omitted in non-Unicode programs . If the addition ENCODING is not specified in non-Unicode programs, the addition NON-UNICODE is used implicitly.

ABAP_PGL Write text files in UTF-8
and with a byte order mark .
Latest notes: We recommend always writing files in UTF-8 , if all readers can process this format. Otherwise, the code page can depend on the text environment and it is difficult to identify the code page from the file content.

ABAP_ALTERNATIVE_1 ... DEFAULT

What does it do? In a Unicode system, specifying DEFAULT is the same as specifying UTF-8 ; in a non-Unicode system, it is the same as NON-UNICODE .

ABAP_ALTERNATIVE_2 ... UTF-8 [SKIPPING|WITH BYTE-ORDER MARK]

ABAP_ADDITION:
... SKIPPING|WITH BYTE-ORDER MARK

What does it do? The characters in the file are handled in accordance with the Unicode character representation UTF-8
.

Latest notes: The class
CL_ABAP_FILE_UTILITIES contains the method CHECK_UTF8 for determining whether a file is a UTF-8 file.
A UTF-16 file can only be opened as a binary file.

ABAP_ADDITION ... SKIPPING|WITH BYTE-ORDER MARK

What does it do? This addition defines how the byte order mark (
BOM ), with which a file encoded in the UTF-8 format can begin, is handled. The BOM is a sequence of three bytes that indicates that a file is encoded in UTF-8
.
SKIPPING BYTE-ORDER MARK
is only permitted if the file is opened for reading or changing using FOR INPUT or FOR UPDATE . If there is a BOM at the start of the file, this is ignored and the file pointer is set after it. Without the addition, the BOM is handled as normal file content.

WITH BYTE-ORDER MARK
is only permitted if the file is opened for writing using FOR OUTPUT . When the file is opened, a BOM is inserted at the start of the file. Without the addition, no BOM is inserted.
The addition BYTE-ORDER MARK cannot be used together with the AT POSITION addition.

Latest notes: When opening UTF-8 files for reading, it is best to always enter the addition SKIPPING BYTE-ORDER MARK to prevent a BOM from being handled as file content.
It is recommended to always open a file for reading as a UTF-8 with the addition WITH BYTE-ORDER MARK , if all readers can process this format.
You can use the method CREATE_UTF8_FILE_WITH_BOM of system class CL_ABAP_FILE_UTILITIES to create a file with BOM .

ABAP_ALTERNATIVE_3 ... NON-UNICODE

What does it do? In a non-Unicode system, the data is read or written without being converted. In a Unicode system, the characters of the file are handled in accordance with the non-Unicode code page that would be assigned at read or write time in a non-Unicode system, in accordance with the entry in the database table
TCP0C of the current text environment .
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved




OPEN_DATASET_CODE_PAGE
OPEN_DATASET_ENDIAN




comments powered by Disqus