ABAP OPEN DATASET statement for open a file

OPEN DATASET statement in ABAP is used for opening a presentation server file in the program. For closing the file CLOSE DATASET statement is used.





[IN BINARY MODE |IN TEXT MODE | IN LEGACY BINARY MODE |IN                                                            LEGACY TEXT]




[TYPE <c>]

[MESSAGE <mess>]

[FILTER <filt>].


Without any addition the OPEN DATASET statement open a file for reading purpose in binary mode. For other purposes we need to specify the statement with the proper additions.


See more details about each additions used with this statement

FOR OUTPUT: Open a file for writing

FOR INPUT: Open an existing file for writing.

Only the difference with OUTPUT addition is, it won’t create new file if it not exists.

FOR APPENDING: Open a file for writing at the end of file.

IN BINARY MODE: This addition opens the file as a binary file. In this mode, the read and write operation doesn’t require interpreting the file contents, the entire data is used in an unchanged form.

IN TEXT MODE: This addition opens the file as a text file. In this mode, read and write operations deal the contents of the file in a line by line way. The addition ENCODING also used with for specifying the character representation for the file.

AT POSITION: This addition is used for specifying an exact position in bytes to read or write. For an example AT POSITION 10 will skip first 10 bytes in the file and the initial read or write operation will start from this position only.

TYPE: This addition is used for specifying further file attributes for passing to the operating system.

MESSAGE: This addition is used for storing the system messages like error messages at the time of opening files.

FILTER: This addition is for specifying the system commands like compress in UNIX.


It always a good practice to use CLOSE DATASET after the processing with the file opened with OPEN DATASET.

Also Read : View Other ABAP Keywords & Syntax -> ABAP Transaction codes

SAP ALECRMSCMSRMSAP Solutions SAP ReferencesSAP BasicsPP ModuleWMSAP Partners
HomeContact & Privacy PolicyTwitter
All of the product names here are trademarks of their respective companies. The site is not affiliated with SAP AG.