SAP OPEN DATASET ERROR HANDLING ABAP Statements



Get Example source ABAP code based on a different SAP table
  


• MESSAGE OPEN DATASET
• IGNORING CONVERSION ERRORS OPEN DATASET
• REPLACEMENT CHARACTER OPEN DATASET

OPEN DATASET, error_handling
Short Reference

ABAP_SYNTAX
... $[MESSAGE msg$]
$[IGNORING CONVERSION ERRORS$]
$[REPLACEMENT CHARACTER rc$] ...

ABAP Addition
1 ... MESSAGE msg
2 ... IGNORING CONVERSION ERRORS
3 ... REPLACEMENT CHARACTER rc

What does it do?
In the case of errors during execution of OPEN DATASET, these additions enable operating system messages to be received, exceptions to be suppressed, and a replacement character to be defined for unknown characters.

ABAP Addition

What does it do?
If an error occurs when a file is opened, the associated operating system message is assigned to the data object msg. A character-like variable can be specified for msg.



Latest notes:

The addition MESSAGE should always be used for the statement OPEN DATASET in order to find the reason why the operating system could not open a file. In case of an error, a message is also written to the developer trace, but only if the trace level is 2 at least.
ABAP_HINT_END



Example ABAP Coding

Output of the operating system message after an attempt to open a file with an empty name.
ABEXA 00469
ABAP_EXAMPLE_END

ABAP Addition

What does it do?
This addition can be used to suppress a catchable exception defined by the class CX_SY_CONVERSION_CODEPAGE. This exception can be raised by reads or writes if a conversion between code pages takes place and a character cannot be converted to the target code page.
This addition is possible when opening text files, legacy text files, or legacy binary files, but not when opening binary files.



Latest notes:

Each non-convertible character is replaced in the conversion either by the character # or by the character defined by the addition REPLACEMENT CHARACTER. The addition IGNORING CONVERSION ERRORS defines whether the user is notified of this by an exception.
This setting can be changed in an opened file using the statement SET DATASET.
ABAP_HINT_END



Example ABAP Coding

See the addition REPLACEMENT CHARACTER.
ABAP_EXAMPLE_END

ABAP Addition

What does it do?
If a conversion between code pages takes place while data is being read or written, every character that cannot be converted to the target code page is replaced by the character specified in rc. rc expects a character-like data object containing a single character. If the addition is not specified, the character # is used as a replacement character.
This addition is possible when opening text files, legacy text files, or legacy binary files, but not when opening binary files.



Latest notes:

If at least one character is replaced by a replacement character in a read or write, the exception defined in the class CX_SY_CONVERSION_CODEPAGE is raised after the conversion, if this is not suppressed by the addition IGNORING CONVERSION ERRORS.
The replacement character of an opened file can be changed using the statement SET DATASET.
ABAP_HINT_END



Example ABAP Coding

When a legacy text file is opened with ID 1101 for codepage 7-Bit USA ASCII, the exception of class CX_SY_CONVERSION_CODEPAGE is suppressed and a replacement character is specified. When data is written to a file, the character ΓΌ is replaced by u without an exception being raised. Compare the example to addition CODE PAGE.
ABEXA 00470
ABAP_EXAMPLE_END

Return to menu