The Report Definition

The Report Definition uses the REPORT program block to format the input records from the Report Driver.

Report definition custreport.4gl:
01 REPORT cust_list(r_custrec)
02  DEFINE r_custrec RECORD
03        store_num  LIKE customer.store_num,
04        store_name LIKE customer.store_name,
05        addr       LIKE customer.addr,
06        addr2      LIKE customer.addr2,
07        city       LIKE customer.city,
08        state      LIKE customer.state,
09        zip_code    LIKE customer.zip_code 
10       END RECORD
11    
12  ORDER EXTERNAL BY r_custrec.state, r_custrec.city 
13
14  FORMAT
15
16   PAGE HEADER
17    SKIP 2 LINES
18     PRINT COLUMN 30, "Customer Listing"
19     PRINT COLUMN 30, "As of ", TODAY USING "mm/dd/yy"
20    SKIP 2 LINES
21
22    PRINT  COLUMN 2, "Store #",
23          COLUMN 12, "Store Name",
24          COLUMN 40, "Address"
25
26    SKIP 2 LINES       
27      
28   ON EVERY ROW
29     PRINT COLUMN 5, r_custrec.store_num USING "####",
30          COLUMN 12, r_custrec.store_name CLIPPED,
31          COLUMN 40, r_custrec.addr CLIPPED;
32
33    IF r_custrec.addr2 IS NOT NULL THEN
34      PRINT 1SPACE, r_custrec.addr2 CLIPPED, 1 space;
35    ELSE 
36        PRINT 1 SPACE;
37    END IF
38
39    PRINT r_custrec.city CLIPPED, 1 SPACE, 
40          r_custrec.state, 1 SPACE, 
41          r_custrec.zip_code CLIPPED
42
43   BEFORE GROUP OF r_custrec.city 
44    SKIP TO TOP OF PAGE
45
46   ON LAST ROW
47    SKIP 1 LINE
48    PRINT "TOTAL number of customers: ", 
49           COUNT(*) USING "#,###"
50
51   PAGE TRAILER
52    SKIP 2 LINES
53    PRINT COLUMN 30, "-", PAGENO USING "<<", " -"
54
55 END REPORT
Note: