Page 1 of 1

RPG Calling LANSA and Receiving a List back

Posted: Thu Sep 26, 2019 12:20 am
by Eugene
Hi All,
I have a prospect that is looking to call a LANSA program using RPG, passing a set of parameters and receiving a list back. I've looked at the documentation on using the exchange list but no mention is made of passing a list of values. Anyone done this before? If so how?
Thanks in advance.
Best Regards,
Eugene

Re: RPG Calling LANSA and Receiving a List back

Posted: Thu Sep 26, 2019 12:45 am
by LANSAGuru
Exchange only passes individual field values. It can not exchange an entire list.

A list must be passed directly
OR
saved to disk as a csv style file and read on the other side. You would pass the IFS file to the other side via exchange.

There are 2 ways to call LANSA from a 3GL.

1. Direct call - this is fairly complicated

2. Simply run the LANSA command...however you can not pass a list this way, but it is way simpler to code (imo). There are a couple of bifs to transform a list into a LANSA list and onto IFS. TRANSFORM_LIST. TRANSFORM_FILE.

Note #1

Exchange must be on to use exchange between 3GL and LANSA.
From the 5250 LANSA menu
Work with Administration Tasks
Review system settings
Execution and Security
Allow LANSA exchange for RPG, etc . . . . . . . . . . . . : Y (set to Y)

Notes #2:

For direct call examples look here...

DCXDTALIB/DC@F28(UD@CALL1)
DCXDTALIB/DC@F28(UD@CALL2)
DCXDTALIB/DC@F28(UD@CALL1)
DCXDTALIB/DC@F28(UD@FUNC1) ****
DCXDTALIB/DC@F28(UD@FUNC2)
DCXDTALIB/DC@F28(UD@FUNC3) ****
DCXDTALIB/DC@F28(UD@FUNC4)

Notes #3

While it is possible to pass a LANSA working list into a 3GL, I am not sure the other way is actually possible. I know you can pass lists between LANSA functions easily enough, but to do that from a 3GL via direct call (#1 above) I don't recall ever having seen code to do this. Without a good example it would be very difficult. [You might want to consult with your local LANSA support desk for this...they might have an example]

Paul

Re: RPG Calling LANSA and Receiving a List back

Posted: Thu Sep 26, 2019 5:21 am
by atostaine
We did it by creating a table with the same fields as the list, plus a job#. In the RPG, we would write the to the file with the next available job#, then pass the job# back.

Then the LANSA program would just do a select to the table with the job#. It worked quick and easy.

Just delete the old records occasionally and set the file to reuse deleted records (reusedlt(*YES)), or clear it when system is not in use.

Re: RPG Calling LANSA and Receiving a List back

Posted: Thu Sep 26, 2019 10:50 pm
by Eugene
Thanks for the suggestions. I've decided to use a temporary table to hold the data passing back a reference number so the RPG can read the data.
Best Regards,
Eugene