CL file operation commands - skill-at/AS-400-Training GitHub Wiki

Receive File (RCVF) command.

Used mostly for database file read in CL. When you run a RCVF command, the next record on the file's access path is read, and the values of the fields defined in the database record format are placed in the corresponding CL variables. Note that CL does not support zoned decimal or binary numbers. Consequently, fields in the database file defined as zoned decimal or binary cause *DEC fields to be defined in the CL procedure or program. *DEC fields are internally supported as packed decimal, and the RCVF command performs the conversion from zoned decimal and binary to packed decimal as required. Database files which contain floating point data cannot be used in a CL procedure or program.

When the end of file is reached, message CPF0864 is sent to the procedure or original program model (OPM) program. The CL variables declared for the record format are not changed by the processing of the RCVF command when this message is sent. You should monitor for this message and perform the appropriate action for end of file. If you attempt to run additional RCVF commands after end of file has been reached, message CPF0864 is sent again.

When the RCVF command reaches the end of the file, you can use the Close Database File (CLOSE) command to close the file. When the file is closed, the next RCVF command implicitly reopens the file and reads a record.

Send receive file command.

Used for display files The Send/Receive File (SNDRCVF) command is used by a CL program or ILE CL procedure to send data to and receive data from a device that is being used interactively by a user. The data is passed between the program in which the SNDRCVF command is used and the display device identified in the command. The data is passed using the display device file that was declared in the program. (A Declare File (DCLF) command included in the source used to compile the program was used to declare the file.) The data for each send/receive operation is passed as one record in a format identified by the RCDFMT parameter of this command (the format is defined in the data description specifications (DDS)). One CL variable is used for each field of the record format to pass the data. The CL variables used (including DDS indicators) are declared implicitly.