1,150 pts.
 Passing parameters thru LDA
Hi i want to know how the parameters can be passed from one RPG program to another RPG program using LDA.Please give me an example code. thanks Ram

Software/Hardware used:
ASKED: April 22, 2009  6:41 AM
UPDATED: August 31, 2011  5:21 PM

Answer Wiki:
Two ways //////////////////////////////////// RPG pgrom can control when lda is broght in with the In operation - loads datastructure updated with the out operation - puts datastructure into LDA D LDAOpt UDS 512 DTAARA(*LDA) D LdaBch# 1 6 0 D LdaRest 7 512 In LDAOpt; LdaBch# = NextBatch#; Out LDAOpt; OR---------- When the UDS datastructure is unnamed The fields are loaded from the LDA at initialization and written to the LDA at end D UDS D LDAF1 278 279 D LDAF2 280 282 D LDAF3 283 283 D LDAF4 284 284 Phil ///////////////////////// The *LDA is part of the job stream. If you put data into it in one RPG or CL program it can be accessed the same way by any subsequent RPG or CL programs in the same job. So if pgm1 has a UDS data structure defined D UDS D LDAF1 278 279 and puts a value in LDAF1 then prm2 in the same job can contrain the same definition D UDS D LDAF1 278 279 and use the data in LDAF1 from pgm1. Phil
Last Wiki Answer Submitted:  April 22, 2009  5:37 pm  by  philpl1jb   44,630 pts.
All Answer Wiki Contributors:  philpl1jb   44,630 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Hi Phil thanks for your reply. But you didn’t tell me how the LDA can be passed to the other RPG program, please elaborate on this…thanks

 1,150 pts.

 

Hi,

You can also access the *LDA from CL programs using CHGDTAARA and RTVDTAARA. You can display the *LDA using DSPDTAARA.

Note that the *LDA is job specific (just like the QTEMP library).

Regards,

Martin Gilbert.

 23,625 pts.

 

It would be better to generate your own data area.. (CRTDTAARA).. Then poplate it with what you want. This way other apps that you may purchase in the future can use LDA and not screw you up…
Example RPG pgm. create the data area with CRTDTAARA…..
D PassLocal UDS Dtaara(EDIPSW)
D PASSDTA 1 10

Begsr *inzsr
IN(E) PassLocal;
Endsr:

 1,780 pts.

 

I have an LDA defined as UDS. One of the fields is QS1 in position 285. There is no move to update the value of this field yet when LR is set on there is a value of ‘Y’. How does the Y get there if it is not moved?

 10 pts.

 

But you didn’t tell me how the LDA can be passed …

You don’t need to “pass” the *LDA between programs. Every job has a *LDA that can be accessed by any program in the job. The *LDA is automatically “passed” in that sense. The only real question, then, is how does an RPG program access the *LDA.

Tom

 110,105 pts.

 

How does the Y get there if it is not moved?

Hard to say. We’d probably need to see the value of the *LDA before the program is called, the source for the program in question, the source for any programs called by that program and the value of the *LDA after the program completes.

I would suggest that this is better handled in a new question that you create.

Tom

 110,105 pts.