Sunday, July 13, 2008

UDS Vs LDA:

When you define a data area using UDS, the RPG program will read it automatically when the program starts, lock it, and update/unlock it only when the program ends. That's what UDS is for.

If you want to read a data area without doing that, use the IN & OUT RPG op-codes instead of UDS.

Here's an example of that:


D LDA DS DTAARA(*LDA)
D RptDate 1 8A
D RptType 105 106A

D MyDtaAra DS 200 DTAARA('QGPL/MYDTAARA')
D LastRun 1 8A
D LastRptType 105 106A

** Load the LDA. This does not lock it.
c in LDA
c dsply RptDate
c dsply RptType

** Load My Data Area. This does not lock it.
c in MyDtaAra
c dsply LastRun
c dsply LastRptType

** Load My Data Area again, this time lock it and update it.
c *lock in MyDtaAra
c eval LastRun = RptDate
c eval LastRptType = RptType
c out MyDtaAra

c eval *inlr = *on

No comments: