According to ACL help, the RECOFFSET() Function "returns a field value from a record that is a specified number of records from the current record." In other words, by using this function, you can have ACL look at another record and utilize values from those records in various analysis. This can be used to identify similar records (EG does the current record have the same value as the previous record?) It can also be used to perform calculations between different records. For example, to calculate the difference between the current and previous record. (Note, it cannot be used to perform
running totals, running totals require group commands.)
While RECOFFSET() is a powerful function it is very inefficeint within a script. Using it to perform ad hoc inquiries in view mode is ok, but using it within a script can kill the script. A simple extract using the RECOFFSET() with a million records could take upwards of an hour. Because of this, most advanced ACL users do not use RECOFFSET in scripts. They will use a GROUP command instead.
GROUPs can be used to emulate RECOFFSET. The basic format for a GROUP is:
COMMENT variables utilized in a GROUP have to be initialized before the GROUP.
V_field name = blank(20)
COMMENT A GROUP will perform the action in the group on each line and then proceed to the next line and repeat. The code will capture the value of the current line with the value of the previous line.
GROUP IF v_field_name = fieldname
EXTRACT FIELDS ALL TO TEMP1
v_field_name = fieldname
ELSE
v_field_name = fieldname
END