ContentsIndexPreviousNext

Code Examples

Code example 1:

If you assume the following group item:

01  GROUP-1.
    03  ELEM-1     PIC X(10).
    03  ELEM-2     PIC X(10).
    03  GROUP-2.
        03  ELEM-3
            OCCURS 10 TIMES PIC X(10).
        03  ELEM-4    PIC X(10).

then, the following procedure division code:

DISPLAY RECORD-POSITION OF ELEM-1, CONVERT, LEFT
DISPLAY RECORD-POSITION OF ELEM-2, CONVERT, LEFT
DISPLAY RECORD-POSITION OF ELEM-3, CONVERT, LEFT
DISPLAY RECORD-POSITION OF ELEM-4, CONVERT, LEFT

would produce the following output:

1
11
21
121

Code example 2:

The RECORD-POSITION construct is particularly useful with the DATA-COLUMNS property of the list box and grid controls. For example, in a list box control, you might have a line that reads:

data-columns - (1, 13, 24, 33 )

changing the line to:

data-columns = (
    record-position of data-key-1,
    record-position of data-city,
    record-position of data-state,
    record-position of data-amount )

makes it easier to understand. With this syntax, changes to the record format do not need to be echoed in the data-columns format, so this is also easier to maintain.