OPEN DATASET

Short Reference

Syntax

OPEN DATASET dset FOR access IN mode [position]
                                     [os_addition]
                                     [error_handling].

Effect

This statement opens the file specified in dset for the access specified in access in a storage mode specified in mode. For dset, a character-type data object is expected, which contains the platform-specific name of the file.

Use the additions position, os_addition, and error_handling to determine the position at which file is opened, specify platform-specific additions, and influence error handling.

In Unicode programs, the access and storage modes access and mode must be specified explicitly. If the additions are missing in non-Unicode programs, the file is opened implicitly as a binary file for read access.

In Unicode programs, the file must not yet be open in the current program; otherwise a treatable exception occurs. In non-Unicode programs, the file may already be open. The statement OPEN DATASET then does not reopen the file but moves the read or write position depending on the access mode. In this case, you should not change the access or storage mode.

Note

You can open up to 100 files per internal session. The actual maximum number of simultaneously open files may be less, depending on the platform.

Return Value

sy-subrc Description
0 File was opened.
8 Operating system could not open file.

Exceptions

Catchable Exceptions

CX_SY_FILE_OPEN

CX_SY_CODEPAGE_CONVERTER_INIT

CX_SY_CONVERSION_CODEPAGE

CX_SY_FILE_AUTHORITY

CX_SY_PIPES_NOT_SUPPORTED

CX_SY_TOO_MANY_FILES

Non-Catchable Exceptions