Where allowed to run:
|
Parameters Examples Error messages |
The Receive File (RCVF) command is used by a CL procedure to receive data from a display device or database file. The command reads a record from the file and puts the data from the record into one or more CL variables. These CL variables were automatically declared in the program when the CL source program was compiled and a Declare File (DCLF) command was processed as part of the source. There is one CL variable for each field in the record format used to receive the data. The data that is entered by a user at the display or is contained in the input record is copied into CL variables in the program by the RCVF command, where it is processed by the program.
Only one record format, of those specified in the DCLF command, can be specified in each RCVF command. If the file has not been opened by a previous RCVF, SNDRCVF, or SNDF command, it is opened by this command. If the file has been previously closed due to an end-of-file condition on a previous RCVF command, an error occurs. The file specified in this command can be overridden if the override command is entered before the file is opened. If the file specified in the DCLF command was a display file when the program was compiled, the file may only be overridden to another display file. If the file was a database file, the file may only be overridden to another database file that has a single record format. However, care should be taken that the fields in the overriding record format correspond to the CL variables declared in the program.
Restrictions:
Top |
Keyword | Description | Choices | Notes |
---|---|---|---|
DEV | Display device | Name, *FILE | Optional, Positional 1 |
RCDFMT | Record format | Name, *FILE | Optional, Positional 2 |
OPNID | Open file identifier | Simple name, *NONE | Optional |
WAIT | Wait | *YES, *NO | Optional |
Top |
Specifies the name of the display device from which data is to be received. If a CL variable name is used in this parameter, only one RCVF command is needed in the program to receive data from several devices. (The variable specifying the device name can be changed while repeatedly running the same command.) This parameter may be specified only if the file is a display device file.
Top |
Specifies the name of the record format that is used to receive data from the file. The format contains all the fields in the record. This parameter must be coded with a record format name if there is more than one record format in the device file. If the file is a database file, the specified record format is used to map the data from the record into the CL variables. The actual record format name in the file at run time may be different. RCVF ignores the INVITE DDS keyword.
Top |
Specifies the open file identifier that was declared on a preceding Declare File (DCLF) command in the same CL procedure. A CL variable cannot be specified for this parameter value.
Top |
Specifies whether the CL procedure waits for the data to be received from the user's device or continues processing the commands that follow this RCVF command. If WAIT(*NO) is specified, the program must issue a WAIT command later in the program to complete the input operation. This parameter may be specified only if the file is a display device file.
Top |
Example 1: Receive Data from Database File
DCLF FILE(MENU1) : RCVF OPNID(*NONE)
The CL procedure receives data from the database file named MENU1. The RCVF command is associated with the Declare File command that does not have an open file identifier specified.
Example 2: Receive Data from Display Device
DCLF FILE(SCREENX) RCDFMT(R1 R2) : RCVF DEV(DISPLAY2) RCDFMT(R1)
The CL procedure receives data from the user at the display station named DISPLAY2. The data is received in the record format named R1 in the device file named SCREENX. The procedure waits for the user data before it continues processing.
Example 3: Handling End-of-File Exception
DCLF FILE(INPUT) OPNID(INFILE1) : RCVF OPNID(INFILE1) MONMSG CPF0864 EXEC(GOTO EOF)
The CL procedure receives a record sequentially from the database file named INPUT. The procedure monitors for the end-of-file exception CPF0864 and goes to label EOF when the message is received.
Example 4: Using RCVF with WAIT command
DCLF FILE(MSCREEN) RCDFMT(MIN1 MIN2 MIN3) : RCVF DEV(&DNAME) RCDFMT(MIN2) WAIT(*NO) WAIT DEV(&DNAME)
The CL procedure receives user data from several devices one at a time by way of the device file named MSCREEN. The procedure receives data from the device named in the variable &DNAME using the record format MIN2, but it does not wait for the data to come in. The same RCVF command is used to receive data from several devices; because the CL variable &DNAME is used, only the device name in the DEV parameter must be changed each time the command is run. A WAIT command for each device must be issued later in the procedure because the WAIT command actually receives the data. Both the RCVF and the WAIT commands may be processed for each device (one at a time) to send data to the procedure. If a user response is delayed, the commands can be processed as many times as necessary until the user responds with the data or a End Receive (ENDRCV) command cancels the request.
Top |
*ESCAPE Messages
Top |