Ansicht
Dokumentation

ABAPOPEN_DATASET - OPEN DATASET

ABAPOPEN_DATASET - OPEN DATASET

RFUMSV00 - Advance Return for Tax on Sales/Purchases   ROGBILLS - Synchronize billing plans  
This documentation is copyright by SAP AG.
SAP E-Book

OPEN DATASET

Short Reference



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

Effect

This statement opens the file specified in dset on the host computer of the current for the access specified in access in a storage mode specified in mode. dset expects a character-like data object containing the physical name of the file. The file must not yet be open in the current program; otherwise a catchable exception is raised.

The additions positions, os_addition, and error_handling can be used to determine the position at which file is opened, specify platform-dependent additions, and can be used for error handling.

Notes

  • Up to 100 files can be opened per internal session. The actual maximum number of simultaneously open files may be less, depending on the platform. If the maximum number of open files is exceeded, a catchable exception is raised.

Access to a file whose name dset is injected into a program from outside is a serious security risk. Any names passed to a program from outside must be checked thoroughly before being used. See Directory Traversal.

Return Value

sy-subrc Meaning
0 The file was opened.
8 The operating system could not open the file.

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

Example

The example demonstrates the following:

  • Opening a file for writes
  • Writing binary XML data to the file
  • Closing the open file
  • Opening the file for reads
  • Reading the binary XML data from the file
  • Closing the open file
  • Deleting the file

The XML data is created by transforming an internal table to the asXML format.

Exceptions

Catchable Exceptions

CX_SY_FILE_OPEN

  • Cause: The file is already open.
    Runtime Error: DATASET_REOPEN

CX_SY_CODEPAGE_CONVERTER_INIT

  • Cause: The required conversion is not supported. (Due to specification of invalid code page or of language not supported in the conversion, with SET LOCALE LANGUAGE.)
    Runtime Error: CONVT_CODEPAGE_INIT

CX_SY_CONVERSION_CODEPAGE

  • Cause: Internal error in the conversion.
    Runtime Error: CONVT_CODEPAGE

CX_SY_FILE_AUTHORITY

  • Cause: No authorization for access to file
    Runtime Error: OPEN_DATASET_NO_AUTHORITY
  • Cause: Authorization for access to this file is missing in OPEN DATASET with the addition FILTER.
    Runtime Error: OPEN_PIPE_NO_AUTHORITY

CX_SY_PIPES_NOT_SUPPORTED

  • Cause: The operating system does not support pipes.
    Runtime Error: DATASET_NO_PIPE

CX_SY_TOO_MANY_FILES

  • Cause: Maximum number of open files exceeded.
    Runtime Error: DATASET_TOO_MANY_FILES

Non-Catchable Exceptions

  • Cause: An attempt was made to open a pipe that is already open.
    Runtime Error: DATASET_PIPE_POSITION






BAL_S_LOG - Application Log: Log header data   ROGBILLS - Synchronize billing plans  
This documentation is copyright by SAP AG.

Length: 7508 Date: 20240328 Time: 101317     sap01-206 ( 73 ms )