This is an example of using a data area to track the status of an order file.
Assume that you are using a data area named ORDINFO to track the status of an order file. This data area is designed so that:
You would declare these fields in your procedure as follows:
DCL VAR(&ORDSTAT) TYPE(*CHAR) LEN(1) DCL VAR(&STOCKC) TYPE(*CHAR) LEN(1) DCL VAR(&CLERK) TYPE(*CHAR) LEN(3)
To retrieve the order status into &ORDSTAT, you would enter the following:
RTVDTAARA DTAARA(ORDINFO (1 1)) RTNVAR(&ORDSTAT)
To retrieve the stock condition into &STOCK, you would enter the following:
RTVDTAARA DTAARA(ORDINFO (2 1)) RTNVAR(&STOCKC)
To retrieve the clerk's initials into &CLERK, you would enter the following:
RTVDTAARA DTAARA(ORDINFO (3 3)) RTNVAR(&CLERK)
Each use of the RTVDTAARA command requires the data area to be accessed. If you are retrieving many subfields, it is more efficient to retrieve the entire data area into a variable, then use the substring built-in function to extract the subfields.