OPEN DATASET - os_additions

Syntax

... [TYPE attr]
    [FILTER opcom] ... .

Extras:

1. ... TYPE attr

2. ... FILTER opcom

Effect:

You can use these additions to make operating system- specific settings and set operating system statements.

Addition 1

... TYPE attr

Effect:

The behavior of this addition depends on the operating system of the application server. If you are not dealing with am MS Windows operating system, a character-type field can be specified for attr that contains operating system-specific parameters for the file that is to be opened. These parameters are transferred to the operating system of the application server 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 marking of the text file:

  1. If attr contains the value "NT", the end-of-line is marked by "CRLF".

  2. If attr contains the he 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 marking is opened in the same way as described in the addition WITH LINEFEED.

Note

Instead of specifying the values "UNIX" or " NT" after TYPE, we recommend using the addition WITH LINEFEED. If it is used, you cannot specify the values "UNIX" or "NT".

Example:

Creating a file test.dat. The properties entered under TYPE are specific for the operating system OS/400.

OPEN DATASET 'test.dat'
  TYPE 'lrecl=80, blksize=8000, recfm=FB'
  FOR OUTPUT IN TEXT MODE
             ENCODING DEFAULT
             WITH SMART LINEFEED.

Addition 2

... FILTER opcom

Effect:

This addition can be used if the operating system of the application server supports pipes (Unix and MS Windows). A character-type 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 STDOUT of the process, from which the data is read during file reading. The file itself is linked with STDIN of the process. When the file is opened for writing, a channel (pipe) is linked to STDIN of the process, to which data is transferred during writing. The output of the process is diverted to this file.

The addition FILTER must not be used together with the addition AT POSITION or for the access type FOR UPDATE.

Note:

When working with pipes, you need to ensure that the pipe only exists in the current work process. If a change of work process takes place during the time that the file is open, the pipe is lost and an attempted read or write access leads to a treatable exception of the class CX_SY_PIPE_REOPEN.

Example:

On a Unix platform, a compress filter is started for writing, and an uncompress filter is started for reading. When the file is accessed for writing the data is compressed, and when it is accessed for reading, the data is decompressed.

DATA file TYPE string VALUE `/usr/test.Z`.

OPEN DATASET file FOR OUTPUT IN BINARY MODE
                      FILTER 'compress'.
...
CLOSE DATASET file.

OPEN DATASET file FOR INPUT IN BINARY MODE
                      FILTER 'uncompress'.
...
CLOSE DATASET file.