1 /* A sample program to illustrate many of the MRPG features.  This is
 2  *       filing_cabinet.mrpg  in  >unbundled>mrpg_examples.archive  */
 3 
 4 declare 1 parameter, 2 where_to_send_output boolean key ("-file");
 5 
 6 declare 1 input  stream
 7          file "filing_cabinet.mrpg.input",
 8          2 grade              char(1)  position  1,
 9          2 drawers            dec(1)   position  4,
10          2 quantity           dec(3)   position  7,
11          2 unit_cost          dec(3)   position 12;
12 
13 declare quantity_total  dec;   declare quantity_grand_total  dec;
14 declare cost_total      dec;   declare cost_grand_total      dec;
15 
16 declare grade_code_to_name table
17   ("c" -> "Commercial"  "f" -> "Fireproof"  "u" -> "Utility") varying;
18 declare grade_code_to_supplier table
19   ( "c" -> "Cranston Office Furniture"
20     "f" -> "Firesafe Specialities"
21     "u" -> "Universal Metal Products" ) varying;
22 
23 define 1 report filing_cabinet_inventory   break (grade)   pagelength 46
24         on (file "filing_cabinet.report" if (where_to_send_output)
25             or switch "user_output"),
26 2 pagehead, 3 line 4, 4 "FILING CABINET INVENTORY AS OF "  ||  %mmddyy,
27             3 line +2,
28 2 detailhead grade,
29  3 line +3,
30   4 "Grade:  ",
31   4 transform (grade, grade_code_to_name)  let (quantity_total := 0;),
32   4 "--  Purchased from:  ",
33   4 transform (grade, grade_code_to_supplier) let (cost_total := 0;),
34 
35  3 line +2,
36   4 "N^H__^Ho.^H___^Ho_^Hf_D^H__^Hr_^Ha_^Hw_^He_^Hr_^Hs"     column 11,     4 "Q^H__^Hu_^Ha_^Hn_^Ht_^Hi_^Ht_^Hy"           column 26,
37   4 "U^H__^Hn_^Hi_^Ht_C^H__^Ho_^Hs_^Ht"          column 36,     4 "E^H__^Hx_^Ht_^He_^Hn_^Hd_^He_^Hd_C^H__^Ho_^Hs_^Ht"      column 47,
38  3 line +2,
39 /* Next line provides column numbers for the reader's convenience. */
40   4 "----+----1----+----2----+----3----+----4----+----5----+----6",
41  3 line,
42 2 detail the_data_line,
43  3 line,
44   4 drawers                   column 17 picture "9",
45   4 quantity                  column 31 picture "zz9",
46   4 unit_cost                 column 37 picture "$z,zz9",
47   4 quantity * unit_cost      column 51 picture "$zz,zz9"
48     let ( quantity_total := quantity_total + quantity;
49           cost_total := cost_total + quantity * unit_cost; ),
50 2 detailfoot grade,
51  3 line +2,
52   4 "   TOTALS: QUANTITY = ",
53   4 quantity_total            column 30 picture "zzz9",
54   4 "COST"                    column 44,
55   4 cost_total                column 50 picture "$zzz,zz9"
56    let (quantity_grand_total := quantity_grand_total + quantity_total;
57          cost_grand_total := cost_grand_total + cost_total; ),
58 2 pagefoot,
59  3 line 46,
60   4 "   GRAND TOTALS: QUANTITY = ",
61   4 quantity_grand_total      column 29 picture "zzzz9",
62   4 "COST   ="                column 40,
63   4 cost_grand_total          column 49 picture "$zzzz,zz9";
64 
65 begin ()   hold input;
66 begin ( quantity_grand_total := 0; cost_grand_total := 0;)
67 sort grade, drawers;    print the_data_line;    end;