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


Demonstration

Objective

This report uses a forced control break to make individual plant and division codes available for labeling print lines.

Procedure

Complete Code

col. 2
▼
REC PLANT       3  2
REC AMOUNT      5  4  2  DP=2
01SORT DIVISION 0  PLANT 0  WORK-X +   $Forced control break
013 SALES BY PLANT AND DIVISION
010 COUNT 1
010 PLANT-SAVE '  '
010 DIV-SAVE '  '
010 WORK-X
01OUT T
0151*0000 COUNT
0151*020  AMOUNT F2 SZ=7
017100    WORK-X + 1  WORK-X         $Increment work field value
0161*005  DIVISION      HH 'DIVISION'    $Headings and first detail line
0161*010  PLANT         HH 'PLANT'
0161*020  AMOUNT  SZ=7  HH '  AMOUNT'
0161*025  ' '           HH 'COUNT'
0162*0100 PLANT                         $Plant subtotal
0162*020  AMOUNT  SZ=7
0162*025  COUNT   SZ=2                   $Plant records processed
0163*0050 DIVISION                      $Division subtotal
0163*021  AMOUNT  SZ=7
0163*025  COUNT   SZ=2                   $Division records processed
0164*0050'GRAND TOTAL'                $Grand total
0164*022  AMOUNT  SZ=7
0164*025  COUNT   SZ=2                   $Total number of record processed
0165*020  AMOUNT  SZ=7                   $Unlabeled detail lines
018010    IF LEVL = 4  400              $Go to grand total print routine
018020    IF LEVL = 3  300              $Go to the division print routine
018030    IF LEVL = 2  200              $Go to the plant print routine
018040    IF DIVISION = DIV-SAVE AND PLANT = PLANT-SAVE 100
018050    MOVE PLANT TO PLANT-SAVE
018055    MOVE DIVISION TO DIV-SAVE
018060    TAKE 1
018100    TAKE 5
018200    TAKE 2
018300    TAKE 3
018400    TAKE 4

Result

REPORT NO. 01 SALES BY PLANT AND DIVISION mm/dd/yy PAGE 1 DIVISION PLANT AMOUNT COUNT 01 01 50.00 20.00 20.00 01 90.00 3 01 02 40.00 50.00 02 90.00 2 01 180.00 5 02 02 20.00 40.00 02 60.00 3 02 60.00 3 06 03 40.00 03 40.00 1 06 40.00 1 GRAND TOTAL 280.00 9