OPEN DATASET with addition FILTER returns SY-SUBRC = 0, although
the specified file does not exist or cannot be written to.
After the CLOSE DATASET on a file that was opened with FILTER, sy-subrc, for example, may have the value -1, 256 or another value that is usually not set by the filter command or filter program.
The command OPEN DATASET with addition FILTER opens a pipe. The operating system opens an additional process that executes the filter command. The input or output of the ABAP file interface is diverted using this pipe.
This subordinate process may terminate before the file is explicitly closed using CLOSE DATASET. One reason may be an early termination of the filter program due to a program error. In such a case, a zombie process is created, whose status (exit code) cannot always be checked during the subsequent program run.
In general, keep in mind that the exit code of the pipe does not necessarily correspond to the return value of the pipe command, but may correspond to the return value of the operating system function pclose() that is used to close the pipe.
1. OPEN DATASET ... FILTER ...
The command OPEN DATASET file FILTER command FOR OUTPUT ..
corresponds to the Unix pipe
( command > file )
When you open the pipe, a UIX operating system
reports the successful program start. The fact that write problems occurred for the executed command can be determined only when the file or pipe is closed.
For this reason, you can determine whether the pipe was processed successfully only when sy-subrc is queried during CLOSE DATASET.
2. SY-SUBRC during CLOSE DATASET on a file opened with FILTER.
Also refer to Notes 790017 and 790191.
- If the exit code of the pipe is no longer available, sy-subrc = -1 is set.
- On most UNIX systems, exit code > 255 means an abnormal termination of the called program (or the shell that is used to interpret the command string). A more exact interpretation of the exit code is available in your UNIX documentation under keywords 'pclose' and 'wait'.
To query the exit code of the executed pipe command reliably during CLOSE DATASET, the called program should obey the following points:
Do not use the pipe to call a program that terminates early with exit() or return from the main() function without waiting for EOF ("end of file") by stdin. Ensure that the pipe called using OPEN DATASET ..is closed by closing stdin, and not before that.
However, a program called as a pipe should close as soon as the EOF is received, because the ABAP program stops in the CLOSE DATASET command and waits for the called program to end.
No comments:
Post a Comment