The Report Driver

The Report Driver for this example, custreports.4gl defines a cursor to retrieve customer table rows sorted by state, then city. The START REPORT statement initializes the report and provides destination and page setup information to the Report Definition.

Report Driver custreports.4gl:
01 SCHEMA custdemo
02
03 MAIN
04 DEFINE pr_custrec RECORD
05   store_num  LIKE customer.store_num,
06   store_name LIKE customer.store_name,
07   addr       LIKE customer.addr,
08   addr2      LIKE customer.addr2,
09   city       LIKE customer.city,
10   state      LIKE customer.state,
11   zip_code    LIKE customer.zip_code 
12  END RECORD
13
14  CONNECT TO "custdemo"
15
16  DECLARE custlist CURSOR FOR
17     SELECT store_num,
18            store_name,
19            addr,
20            addr2,
21            city,
22            state,
23            zip_code 
24       FROM customer 
25      ORDER BY state, city 
26
27  START REPORT cust_list TO FILE "customers.txt" 
28    WITH LEFT MARGIN = 5, TOP MARGIN = 2, 
29          BOTTOM MARGIN = 2
30
31  FOREACH custlist INTO pr_custrec.*
32   OUTPUT TO REPORT cust_list(pr_custrec.*)
33  END FOREACH
34
35  FINISH REPORTcust_list
36
37  DISCONNECT CURRENT
38
39 END MAIN
Note: