CL Programming
Two types of files are supported in CL procedures and programs, display
files and database files. You can send a display to a work station and
receive input from the work station 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 RCVF commands.
To use a file in a CL procedure or program, you must:
- Format the display or database record, identifying fields and conditions
which you enter as DDS source. The use of DDS is not required for a
database file.
- Create the file using the Create Display File (CRTDSPF) command, Create
Physical File (CRTPF) command, or Create Logical File (CRTLF) command.
Subfiles (except for message subfiles) are not supported by CL procedures and
programs.
- For database files, add a member to the file using the Add Physical File
Member (ADDPFM) command or Add Logical File Member (ADDLFM) command.
This is not required if a member was added by the CRTPF or CRTLF
commands. The file must have a member when the procedure or program is
processed, but does not need to have a member when the procedure or program is
created.
- Refer to the file in the CL procedure using the DCLF command, and refer to
the record format on the appropriate data manipulation CL commands in your CL
source.
- Create the CL module.
- Create the program or service program.
Only one display or database file 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 file may be either a physical or logical file, and a logical file may
be defined over multiple physical file members.
- Only input operations, with the RCVF command, are allowed. The
SNDF, SNDRCVF, ENDRCV, WAIT and DEV parameters on the RCVF command 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 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.
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.

You can use the methods discussed in the Application Display Programming
book or the Screen Design Aid (SDA) to enter DDS source for records and
fields in the display file. See the
A CL procedure or program can use several commands, called data
manipulation commands. These commands let you refer to a display file
to send data to and receive data from device displays. These commands
also allows you to refer to a database file to read records from a database
file. These commands are:
- Declare File (DCLF). Defines a display or database file to be used
in a procedure or program. The fields in the file are automatically
declared as variables for use in the procedure or program.
- Send File (SNDF). Sends data to the display.
- Receive File (RCVF). Receives data from the display or
database.
- Send/Receive File (SNDRCVF). Sends data to the display; then
asks for input and, optionally, receives data from the display.
- Override with Display File (OVRDSPF). Allows a run-time override of
a file used by a procedure or program with a display file.
- Override with Database File (OVRDBF). Allows a run-time override of
a file used by a procedure or program with a database file.
These commands let a running program communicate with a device display
using the display functions provided by DDS, and to read records from a
database file. DDS provides functions for writing menus and performing
basic application-oriented data requests that are characteristic of many CL
applications.

The fields on the display or in the record are identified in the DDS for
the file. In order for the CL procedure or program to use the fields,
the file must be referred to in the CL procedure or program by the DCLF
command. This reference causes the fields and indicators in the file to
be declared automatically in your procedure or program as variables.
You can use these variables in any way in CL commands; however, their
primary purpose is to send information to and receive information from a
display. The DCLF command is not used at run time.
The format of the display and the options for the fields are specified in
the device file and controlled through the use of indicators. Up to 99
indicator values can be used with DDS and CL support. Indicator
variables are declared in your CL procedure or program in the form of logical
variables with names &IN01 through &IN99 for each indicator that
appears in the device file record formats referred to on the DCLF
command. Indicators let you display fields and control data management
display functions, and provide response information to your procedure or
program from the device display. Indicators are not used with database
files.
[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.