Previous Topic: $DSCALL OPT=PRINT

Next Topic: $DSCALL OPT=RENAME


$DSCALL OPT=READ

Reads one or more records from a data set.

&CONTROL SHRVARS=($DS)
EXEC $DSCALL OPT=READ 
             DATA= { * | variable_name [ , variable_name,... ] | prefix*} 
           { DD=DD_name | ID=path_name } 
           [ LIMIT= number ] 
           [ TRUNCATE= number ]

This option is used to read records from a data set or a member of a PDS into variables. The procedure must have an open path to the data set or PDS member to be read (use $DSCALL OPT=OPEN to open a path).

Operands:

OPT=READ

Specifies that a read action be performed.

DATA={ * | variable_name [ , variable_name... ] | prefix*}

Specifies the records to be read.

DD=DD_name

Specifies the ddname of the file to be read. This operand is used as the path ID if the ID parameter is not set. The path ID specified must already have been created with an OPT=OPEN or OPT=FOPEN call.

ID=path_name

Specifies the path ID of the file to be read.

Note: Any combination of OPEN, FOPEN, CLOSE, FCLOSE, READ, and WRITE requests must be done in a single procedure.

LIMIT=number

Specifies the maximum number of records to be read from the file. The value of the LIMIT operand must be in the range 1 to 9,999. This operand is applicable only if DATA=* or DATA=prefix* is specified.

TRUNCATE=number

Specifies the length to which records read from the file are truncated. The value of the TRUNCATE operand must be in the appropriate range for the value specified for the DATA operand:

Return Codes:

Note: For more information about &SYSMSG, &$DSRC, and &$DSFDBK, see Return Codes and Feedback Codes.

$DSFDBK is set to 9 and $DSRC set to 4 if the number of records specified by the LIMIT operand is not satisfied.

Return Variables:

&$DSDATAn

Contains the records for the DATA=* option, where n is a number to identify each return. If the DATA=variable_name operand is used, the nominated variables contain the data

&$DSDATA#

Contains the count of records read. For DATA=* it contains the number of records read on this call.

&$DSEOF

End of file indicator. The value is null unless the end of file is encountered. If end of file is encountered, this variable is set to the value EOF. If DATA=variable_name is specified, no data is returned if the end of file is encountered.

Examples: OPT=READ

&CONTROL SHRVARS=($DS)
EXEC $DSCALL OPT=READ ID=SYSPATH DATA=* +
   LIMIT=9999
&CONTROL SHRVARS=($DS, ABC)
EXEC $DSCALL OPT=READ ID=SYSPATH DATA=ABC
&CONTROL SHRVARS=($DS, ABC)
EXEC $DSCALL OPT=READ ID=SYSPATH +
   DATA=ABC* LIMIT=9999