Getting Started with TRANSACT (32247-90007)

Chapter 4 77
Using KSAM and MPE
Using KSAM
Figure 4-3. Program to Update Data in a KSAM File
10 In the KSAM file, both data items are key fields. Therefore, to change a
field we need to add a new record and delete the old. We can code the steps
ourselves, or we can take advantage of the REPLACE capability in
Transact. SET(UPDATE) prepares to let Transact do the delete and add
for us. In this statement, we tell Transact each field that we are going to
update.
11 REPLACE does the add and delete, thereby changing the value for name
to the new value we input.
Figure 4-4. Updating Data in a KSAM File
1 system ex33,ksam=kcust(update);
2 set(delimiter) "/";
3 list(auto) kcust;
5 data cust-no;
6 set(key) list (cust-no);
7 get kcust;
8 display;
9 data name;
10 set(update) list(name);
11 replace kcust;
12 end;
CUST-NO> 301
CUST-NO: NAME:
301 Wheeler Dealer
NAME> My Place
CUST-NO> 301
CUST-NO: NAME:
301 My Place
NAME> ]