The $RRN function is used with VSAM RRDS files to access a specific record or range of records. This function returns the current relative record number at each iteration of the FOR construct. You can use the $RRN function in the WHERE clause of a FOR statement, as the source operand in SET statements, and in expressions.
This function has the following format:
$RRN[(dataview‑name)]
The name of a VSAM dataview that defines an RRDS file. The dataview name is required for this function, except when the function is used in a WHERE clause. You cannot specify the dataview name for this function in the WHERE clause.
Examples
In the following example, the $RRN function is used in the WHERE clause in a FOR NEW statement to add records in consecutive slots in an RRDS file named PAYROLL. To find the last record in the existing file, a FOR FIRST construct is used with an ORDERED BY DESCENDING clause. The working data field NEXT‑REC is set by adding 1 to the number the $RRN function returns.
FOR FIRST PAYROLL
ORDERED BY DESCENDING
SET NEXT‑REC = $RRN(PAYROLL) + 1
WHEN NONE
SET NEXT‑REC = 1
ENDFOR
FOR NEW PAYROLL
WHERE $RRN = NEXT‑REC
statements
SET NEXT‑REC = $RRN(PAYROLL) + 1
ENDFOR
In the next example, the $RRN function finds a specific record in the PAYROLL file.
FOR FIRST PAYROLL
WHERE $RRN = 6
statements
ENDFOR
|
Copyright © 2015 CA Technologies.
All rights reserved.
|
|