Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Processing External Data →  ABAP File Interface →  Statements for the ABAP File Interface →  OPEN DATASET 

OPEN DATASET - access

Short Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


... INPUT 
  | OUTPUT
  | APPENDING
  | UPDATE ...

Alternatives

1. ... INPUT

2. ... OUTPUT
3. ... APPENDING

4. ... UPDATE

Effect

These mandatory additions are used to open the file for reading, writing, appending, or changing.


Note

No addition for the storage type needs to be specified in obsolete non-Unicode programs. If no addition is specified, the file is opened to be read implicitly.

Alternative 1

... INPUT

Effect

The addition FOR INPUT opens the file for reading. By default, the file pointer is set to the start of the file. If the file specified does not exist, sy-subrc is set to 8. Writes cannot be performed on a file opened for reads.


Note

In obsolete Unicode programs, it is possible to perform writes on a file that is open for reading.

Alternative 2

... OUTPUT

Effect

The addition FOR OUTPUT opens the file for writing. If the specified file already exists, its content is deleted. If the file specified does not exist, it is created. Reads are also permitted.

Alternative 3

... APPENDING

Effect

The addition FOR APPENDING opens the file for appending. If the file specified already exists, it is opened and the file pointer is set at the end of the file. If the file specified does not exist, it is created. Attempted reads to a file opened with FOR APPENDING with the statement READ DATASET fail, and return the value 4 for sy-subrc.

Alternative 4

... UPDATE

Effect

The addition FOR UPDATE opens the file for changes to the existing content. By default, the file pointer is set to the start of the file. If the specified file does not exist, no file is opened and sy-subrc is set to 8.