Previous Topic: What You Can DoNext Topic: Obtaining Specific Field Values


Demonstration

Objective

This report lists the quarterly gain or loss for a series of stores by retrieving the accumulated totals value for each occurrence of the subscripted work field GAIN-OR-LOSS.4.

Procedure

Complete Code

col. 2
▼
IN 80 F 320 PS(TAPE)
REC STORE        1  3  2
REC INCOME       4                 GROUP AA 8.4
REC QTR          1  8  2  DP=2     ELMNT AA
REC EXPEND      36                 GROUP BB 8.4
REC AMT          1  8  2  DP=2     ELMNT BB
010 GAIN-OR-LOSS.4 DP=2
010 INDEX 1
013 PROFIT/LOSS REPORT ── yyyy
0151*010 STORE             HH 'STORE'
0151*020 GAIN-OR-LOSS.1 SZ=11 F3 HH ' FIRST QUARTER'
0151*030 GAIN-OR-LOSS.2 SZ=11 F3 HH 'SECOND QUARTER'
0151*040 GAIN-OR-LOSS.3 SZ=11 F3 HH ' THIRD QUARTER'
0151*050 GAIN-OR-LOSS.4 SZ=11 F3 HH 'FOURTH QUARTER'
0161*0200GAIN-OR-LOSS.1 SZ=11 F3                  $Quarterly totals
0161*030 GAIN-OR-LOSS.2 SZ=11 F3
0161*040 GAIN-OR-LOSS.3 SZ=11 F3
0161*050 GAIN-OR-LOSS.4 SZ=11 F3
017100 COMPUTE QTR.INDEX - AMT.INDEX  GAIN-OR-LOSS.INDEX
017    INDEX + 1  INDEX
017    IF INDEX LE 4 100
017    MOVE 1 TO INDEX
017    TAKE

Result

REPORT NO. 01          PROFIT/LOSS REPORT ── yyyy          mm/dd/yy PAGE     1              STORE            FIRST QUARTER           SECOND QUARTER            THIRD QUARTER           FOURTH QUARTER                 1                 19,900.21                10,788.50                53,899.98                19,895.00                10                      0.21                 1,388.41                    99.98                 2,895.76                11                  5,099.79-               34,788.50                17,900.00                19,895.00                21                 44,900.21                10,211.50-              123,899.98                70,104.50-                                   59,700.84                36,753.91               195,799.94                27,418.74-