Getting Started with TRANSACT (32247-90007)
84 Chapter5
Automatic Error Handling and Prototyping
Figure 5-3. Prototype Program to Add Multiple Master Records
Here we have added an additional level (line 3.1) to our program to control entering each
order; we still retain the level that controls adding order lines.
We also added a test to see whether the [[ENTER]] key was last pressed (lines 9.1 to 9.2) or
whether one of the function keys was pressed (pressing [[ENTER]] sets 0 to lastkey;
pressing any function key sets the number of that key to lastkey). Pressing any of the
function keys (lines 14 to 18) is our way of indicating that all order lines have been entered
and we want to enter a new order now.
1 system ex37,base=orders,vpls=formfile;
1.1 define(item) lastkey i(4):
1.2 enter i(4),init=0;
1.3 list lastkey:
1.4 enter;
2 list(auto) vorderhead;
3 list(auto) vorderline;
3.1 level;
4 get(form) vorderhead,init,freeze;
5 put orderhead,list=(order-no,
6 cust-no,
7 order-status,
7.01 order-date);
8 level;
9 get(form) vorderline,init,append,fkey=lastkey;
9.1 if (lastkey) = (enter)
9.2 then
10 put orderline,list=(order-no,
11 line-no,
12 part-number,
13 quantity)
14 else
15 do
16 set(form) vorderline,clear;
17 end(level);
18 doend;