Send/Receive File (SNDRCVF)

Where allowed to run:
  • Batch program (*BPGM)
  • Interactive program (*IPGM)
Threadsafe: No
Parameters
Examples
Error messages

The Send/Receive File (SNDRCVF) command is used by a 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.

Of the record formats specified in the DCLF command, only one can be specified in each SNDRCVF command. If the device file has not been opened, it is opened by this command. The file and record format specified in this command can be overridden by an Override with Display File (OVRDSPF) command if that command is entered before the file is opened. However, care should be taken that the fields in the overriding record format correspond to the CL variables declared in the program.

Restrictions: This command is valid only within a CL procedure and only for display files. It cannot be used with database files.

Top

Parameters

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

Display device (DEV)

Specifies the name of the display device that the CL procedure's data is to be sent to and the user's data is to be received from. A CL variable can be specified for this parameter so that the device name can be changed without changing the command.

*FILE
The data is to be sent to and received from the device associated with the device file (the device file that was declared in the FILE parameter of the DCLF command). If more than one device name is specified in the device file, *FILE cannot be specified.
name
Specify the name of the device or the name of the CL variable that contains the name of the device that the CL procedure is to send data to and receive data from. If a CL variable name is used in this parameter, only one SNDRCVF command is needed in the program to receive data from several devices.
Top

Record format (RCDFMT)

Specifies the name of the record format that is to be used to pass the data between the CL procedure and the user. 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; *FILE cannot be coded if there is more than one. SNDRCVF ignores the INVITE DDS keyword.

*FILE
There is only one record format in the device file; that format is to be used to send the data to and receive the data from the user.
name
Specifies the name of the record format in which the data is to be sent to and received from the user. A CL variable name cannot be used to specify the record format name.
Top

Open file identifier (OPNID)

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.

*NONE
No open file identifier is provided. This command will use the file associated with the DCLF command that had *NONE specified for the OPNID parameter. Only one file can be declared in a CL procedure with *NONE as the open file identifier.
simple-name
Specify a name that matches the OPNID parameter value on a preceding DCLF command in the same CL procedure.
Top

Wait (WAIT)

Specifies whether the CL procedure either waits to receive the data from the user's device or continues to process the commands that follow this SNDRCVF command. If WAIT(*NO) is specified, the program must issue a WAIT command later in the program to complete the input operation.

Note: A CL variable cannot be coded on this parameter.

*YES
The program waits until the input operation from the device is completed; the next command is not processed until then.
*NO
The program does not wait for the input data; it continues to process commands until a WAIT command is reached later in the program.
Top

Examples

Example 1: Using Display File with One Record Format

DCLF   FILE(MENU1)
 :
SNDRCVF

This command sends and receives user data by way of the device file MENU1. Only one record format exists in the file. The device used is specified in the file.

Example 2: Using Display File with Multiple Record Formats

DCLF   FILE(SCR)  RCDFMT(REC8)
 :
SNDRCVF   RCDFMT(REC8)

The CL procedure sends data to a user and receives data for the user who is using the device named in the device file (*FILE is assumed because DEV is not specified). The data is passed in the format specified by REC8 record format in the device file named SCR. The CL procedure waits for the user data before continuing.

Example 3: Using a CL Variable for Device Name

DCLF   FILE(DF1)  RCDFMT(REC8)
 :
SNDRCVF   DEV(&DN)  RCDFMT(REC8)  WAIT(*NO)
 :
WAIT   DEV(&DN)

This command sends and receives user data by way of the device file named DF1. Using the record format REC8, the CL procedure passes data between itself and the user who is at the device named in the variable &DN, but it does not wait for a response to come back. If the procedure sends and receives data from several devices, the same SNDRCVF command can be used. Only the device specified by &DN for the DEV parameter must be changed. A WAIT command for each device must be issued later in the procedure to ensure that all the devices respond.

Example 4: Using Open File Identifier

DCLF   FILE(SCREEN1)  RCDFMT(REC1 REC2)  OPNID(OUTDSP1)
DCLF   FILE(SCREEN2)  RCDFMT(REC3 REC4)  OPNID(OUTDSP2)
 :
SNDRCVF   DEV(*FILE)  RCDFMT(REC2)  OPNID(OUTDSP1)  WAIT(*YES)

The device file named SCREEN1 is used to send data to the display device named in the same device file and wait for input. The data is presented to the user in the format specified by record format REC2. The SNDRCVF command is associated with device file SCREEN1 because the open file identifier specified on the SNDRCVF command matches the open file identifier specified on the DCLF command for display file SCREEN1.

Top

Error messages

*ESCAPE Messages

CPF0859
File override caused I/O buffer size to be exceeded.
CPF0861
File &1 in library &2 is not a display file.
CPF0863
Value of binary data too large for decimal CL variable.
CPF0864
End of file detected for file &1 in &2.
CPF0883
*FILE not valid in DEV parameter for file &1.
CPF0886
Record contains a data field that is not valid.
CPF0887
Data available from previous input request.
CPF4101
File &2 in library &3 not found or inline data file missing.
CPF5068
Program device &4 not found in file &2 in library &3.
CPF5070
File &2 in library &3 has no program devices acquired.
Top