SAP OPEN DATASET OS ADDITION ABAP Statements



Get Example source ABAP code based on a different SAP table
  


• TYPE OPEN DATASET
• FILTER OPEN DATASET

OPEN DATASET, os_additions
Short Reference

ABAP_SYNTAX
... $[TYPE attr$]
$[FILTER opcom$] ...

ABAP Addition
1 ... TYPE attr
2 ... FILTER opcom

What does it do?
These additions can be used to make operating system-specific settings and set operating system statements.

ABAP Addition

What does it do?
The behavior of this addition depends on the operating system of the host computer server of the current ABAP_ASINSTANCE . If the operating system is not an MS Windows operating system, a character-like field can be specified for attr that contains operating system-specific parameters for the file that is to be opened. These parameters are passed to the operating system of the ABAP_ASINSTANCE unchanged, and without being checked for correctness.
If the operating system is an MS Windows operating system, and the file is opened as a text file or as a legacy text file and the addition WITH LINEFEED is not used, the content of attr controls the end-of-line marker of the text file: If attr contains the value NT, the end-of-line is marked by CRLF. If attr contains the value UNIX, the end-of-line is marked by LF.
All other values of attr are ignored in MS Windows operating systems, and the end-of-line marker is opened in the same way as described in the addition WITH LINEFEED.



Latest notes:

Instead of specifying the values UNIX or NT after TYPE, it is best to use the addition WITH LINEFEED. If it is used, the values UNIX or NT cannot be specified.
ABAP_HINT_END



Example ABAP Coding

Creating a file test.dat. The properties entered under TYPE are specific for the operating system IBM i5/OS (previously OS/400).
ABEXA 00477
ABAP_EXAMPLE_END

ABAP Addition

What does it do?
This addition can be used if the operating system of the current ABAP_ASINSTANCE host computer supports pipes (Unix and MS Windows). A character-like field can be specified for opcom, which contains an operating system statement that corresponds to the appropriate command-level syntax.
When the statement OPEN DATASET is executed, a process is started in the operating system for the specified statement. When the file is opened for reading, a channel (pipe) is linked with Standard SAP Help forOUT of the process, from which the data is read during file reading. The file itself is connected to Standard SAP Help forIN of the process. When the file is opened for writing, a channel (pipe) is connected to Standard SAP Help forIN of the process, to which data is passed when writing. The output of the process is redirected to this file.
If, as part of the automatic authorization check for file access, the database table SPTH is used to make a check using the authorization group and the authorization object S_PATH, the current user must have an authorization for the activity A6 (Read) or A7 (Change) when using the addition FILTER.
The addition FILTER must not be used together with the addition AT POSITION or for the access type FOR UPDATE.



Latest notes:

When working with pipes, it must be ensured that the pipe only exists in the current work process. If the work process is switched while the file is open, the pipe is lost and any attempt to read or write raises a catchable exception of the class CX_SY_PIPE_REOPEN.
Pipes should only be used for operating system statements required in association with files. No other operating system statements should be used. The SXPG framework should be used instead. See also Unwanted Calls of Operating System Statements.
When the authorization object S_PATH is checked, for compatibility reasons an empty value is also accepted for the activity alongside the values A6 or A7 if the addition FILTER is used.
ABAP_HINT_END

ABAP_HINT_SEC
Using operating system statements that are passed to a program from outside is a serious security risk. Any statements passed to a program from outside must be checked thoroughly before being used. See System Command Injections.
ABAP_HINT_END



Example ABAP Coding

On a Unix platform, the statement gzip is used as a write filter and the statement gzip -d is used as a read filter. When the file is accessed for writing the data is compressed, and when it is accessed for reading, the data is decompressed.
ABEXA 00478
ABAP_EXAMPLE_END

Return to menu