Reference STATEMENT

PURPOSE:  The REFERENCE statement can be used only in the TOTALS section, and designates whether master field values are to be accessed from the last record of the current subtotals group or from the first record of the next control group.

SYNTAX

REFERENCE\\ {CURRENT; NEXT} /MASTER/ [HUSH] [IF; UNLESS clause]

CURRENT

is the default statement and accesses the last record of the current subtotals group.

NEXT

accesses the first record of the next subtotals group (the record that causes a control break).

Example

TOTALS SECTION
   ON STATE
      PRINT "STATE", 2S, STATE
   IF @EOF EQ "NO"
      REFERENCE NEXT MASTER
      PRINT "ZIP", ZIP

NOTES:  This statement is used to extract data from the first record of the next subtotal group.  In default processing, the next record of the master DS is not advanced until the SUBHEADINGS or one of the Record Processing section’s is executed.  Therefore, if the next master record is needed in either the TOTALS or HEADINGS section, the REFERENCE NEXT statement is used.

The REFERENCE statement can be used in a PM that does not create a report.

This statement has no effect on @RECORD.