RPG Calling LANSA and Receiving a List back

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
Eugene
Posts: 10
Joined: Sat Apr 22, 2017 12:01 am

RPG Calling LANSA and Receiving a List back

Post by Eugene » Thu Sep 26, 2019 12:20 am

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

LANSAGuru
Posts: 68
Joined: Thu Mar 24, 2016 5:31 am

Re: RPG Calling LANSA and Receiving a List back

Post by LANSAGuru » Thu Sep 26, 2019 12:45 am

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

atostaine
Posts: 526
Joined: Wed Jan 20, 2016 7:38 am

Re: RPG Calling LANSA and Receiving a List back

Post by atostaine » Thu Sep 26, 2019 5:21 am

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.
Art Tostaine

Eugene
Posts: 10
Joined: Sat Apr 22, 2017 12:01 am

Re: RPG Calling LANSA and Receiving a List back

Post by Eugene » Thu Sep 26, 2019 10:50 pm

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

Post Reply