Two types of files are supported in CL procedures and programs:
display files and database files.
You can send a display to a workstation and receive input from
the workstation for use in the procedure or program, or you can read data
from a database file for use in the procedure or program.
Note: Database
files are made available for use within the CL procedure or program through
the DCLF and Receive File (RCVF) commands.
To
use a file in a CL procedure or program, you must:
Up to five display or database files can be referred to in a CL procedure.
The support for database files and display files is similar as the same commands
are used. However, there are a few differences, which are described here.
- The following statements apply only to database files used with CL procedures
and programs:
- Only database files with a single record format may be used by a CL procedure
or program.
- The files may be either physical or logical files, and a logical file
may be defined over multiple physical file members.
- Only input operations, with the RCVF command, are allowed. The WAIT and
DEV parameters on the Receive File (RCVF) command are not
allowed for database files. In addition, the SNDF, SNDRCVF, and ENDRCV commands
are not allowed for database files.
- DDS is not required to create a physical file which is referred to in
a CL procedure or program. If DDS is not used to create a physical file, the
file has a record format with the same name as the file, and there is one
field in the record format with the same name as the file, and with the same
length as the record length of the file (RCDLEN parameter of the CRTPF command).
- The file need not have a member when it is created for the module or program.
It must, however, have a member when the file is processed by the program.
- The file is opened for input only when the first Receive File
(RCVF) command is processed. The file must exist and have a member
at that time.
- The file remains open until the procedure or OPM program returns or when
the end of file is reached. When end of file is reached, message CPF0864 is
sent to the CL procedure or program, and additional operations are not allowed
for the file. The procedure or program should monitor for this message and
take appropriate action when end of file is reached.
- The following statements apply only to display files used with CL procedures
and programs:
- Display files may have up to 99 record formats.
- All data manipulation commands (SNDF, SNDRCVF, RCVF, ENDRCV and WAIT)
are allowed for display files.
- The display file must be defined with the DDS.
- The display file is opened for both input and output when the first SNDF,
SNDRCVF, or RCVF command is processed. The file remains open until the procedure
or OPM program returns.
Note: The open does not occur for both types of files until the first
send or receive occurs. Because of this, the file to be used can be created
during the procedure or program and an override can be performed before the
first send or receive. However, the file must exist before the module or program
is compiled.
The format for the display is identified as a record
format in DDS. Each record format may contain fields (input, output, and
input/output), conditions/indicators, and constants. Several record formats
can be entered in one display file. The display file name, record format
name, and field names should be unique, because other HLLs may require it,
even though CL procedures and programs do not.