What does it do? These mandatory additions are used to open the file for reading, writing, appending, or changing.
ABAP Alternative 1 ... INPUT>
What does it do? 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.
Example ABAP Coding
Opens a binary file to read binary data. ABEXA 00460 ABAP_EXAMPLE_END
ABAP Alternative 2 ... OUTPUT>
What does it do? 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 allowed.
Example ABAP Coding
Opens a binary file to write binary data. ABEXA 00461 ABAP_EXAMPLE_END
ABAP Alternative 3 ... APPENDING>
What does it do? 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. An attempt to read to a file opened with FOR APPENDING> with the statement READ DATASET>> fails, and returns the value 4 for sy-subrc>.
Example ABAP Coding
Opens a binary file to append binary data. ABEXA 00462 ABAP_EXAMPLE_END
ABAP Alternative 4 ... UPDATE>
What does it do? 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.
Example ABAP Coding
Opens a binary file to update binary data. ABEXA 00463 ABAP_EXAMPLE_END