Previous Topic: What You Can DoNext Topic: File Matching


Demonstration

Objective

This report prints the third quarter profits for each of six stores.

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
 01OUT T
 010 GAIN-OR-LOSS.4  DP=2                $Four quarters
 010 INDEX 1
 01SORT  STORE 0 GAIN-OR-LOSS.3          $Third occurrence in work field
 013 THIRD QUARTER EARNINGS ── yyyy
 0151*010 ' '                               $One type 5 line is always required
 0161*010 STORE                           HH 'STORE'
* $                                          Retrieve the value:
 0161*020 GAIN-OR-LOSS.3 SZ=11  F3 HH 'THIRD QUARTER PROFIT'
 017100   COMPUTE QTR.INDEX - AMT.INDEX  GAIN-OR-LOSS.INDEX
 017175 IF INDEX EQ 4  200                  $Load subscripted work field
 017    INDEX + 1  INDEX
 017    IF INDEX LE 4 100
 017200 MOVE 1 TO INDEX
 018010 IF LEVL EQ 1 100
 018020 IF LEVL EQ 2 200
 018100 TAKE 1
 018200 DROP

Note: Third Quarter Earnings would be the year in yyyy format.

Result

REPORT NO. 01          THIRD QUARTER EARNINGS ── yyyy       mm/dd/yyPAGE     1                                     STORE                                   THIRD QUARTER PROFIT                                        1                                            53,899.98                                       10                                                99.98                                       11                                            17,900.00                                       21                                           123,899.98

Note: The report would show the actual dates in the format shown.