1 /*  Simple example illustrating  hold  and  sort  */
 2 dcl 1 input stream file "hold_and_sort.mrpg.input",
 3      2 kind char(6), 2 in_stock dec(3), 2 price dec(3);
 4 dcl accum_value dec;
 5 define 1 report bird_value pagelength 14 on file "hold_and_sort.report",
 6  2 pagehead, 3 line 4, 4 "THIS REPORT PRODUCED ON " || %mmddyy, 3 line,
 7   3 line, 4 "Kind    In Stock  Price  Accum Value",
 8   3 line, 4 "------  --------  -----  -----------", 3 line,
 9  2 detail the_data, 3 line,
10    4 kind char(6) left, 4 in_stock char(10) right,
11    4 price char(7) right, 4 accum_value char(13) right
12       let (accum_value := accum_value + in_stock * price;);
13 begin () hold input;
14 begin (accum_value := 0;) sort in_stock desc, price asc;
15 print bird_value;   end;