Page 1 of 1
Retrieving data from the LDA
Posted: Thu Nov 09, 2023 11:28 pm
by jtaljaard
How do we go about retrieving information from an LDA on the ibmi we are referencing the information from the lansa guide:
https://docs.lansa.com/14/en/lansa015/i ... hlight=LDA
But when we do a quick message show, nothing pops up:
here is a snippet of our code:
Define Field(#RETVAL) Type(*VARCHAR) Length(256)
Use Builtin(GET_CHAR_AREA) With_Args('*LDA' '*LIBL' "N" 1 900) To_Get(#RETVAL)
Use Builtin(GET_CHAR_AREA) With_Args("DA_MPY") To_Get(#COMPANY)
Use Builtin(MESSAGE_BOX_ADD) With_Args(#RETVAL)
Use Builtin(MESSAGE_BOX_ADD) With_Args('why')
Use Builtin(MESSAGE_BOX_SHOW)
Not sure if we need to import something specific for this to work or not. Any help would be greatly appreciated.
Re: Retrieving data from the LDA
Posted: Fri Nov 10, 2023 12:40 am
by René Houba
Hi Jared,
A local data area (*LDA) is automatically created on IBMi for each job on the system. It is initially filled with blanks and I think it has a length of 1024, type *CHAR.
This local data area should be filled with something of course.
If you start a session on the IBMi and give command:
DSPDTAARA DTAARA(*LDA)
You see an empty *LDA.
So what is the content of your *LDA when your program (job) is running?
Kind regards,
René
Re: Retrieving data from the LDA
Posted: Fri Nov 10, 2023 1:16 am
by jtaljaard
Hi Rene,
Thanks for your response.
When we sign on it is empty as you said, but when we type in our company and branch code, it then gets populated with the data we want to retrieve which is information regarding our user profile. We then use the code attached previously to try and retrieve the data but nothing gets populated on our message box.
Your assistance will be greatly appreciated. Thank you.
Re: Retrieving data from the LDA
Posted: Fri Nov 10, 2023 3:02 am
by René Houba
Hi Jared,
Where is the code running?
Windows?
Message_box_show seems a Windows program for me, correct?
Kind regards,
René
Re: Retrieving data from the LDA
Posted: Fri Nov 10, 2023 4:17 am
by jtaljaard
the script is running off of a reusable part (there are just a couple of test script we were running):
Begin_Com Role(*EXTENDS #VF_AC010) Height(270) Width(500)
Define_Com Class(#vf_sy122) Name(#POSCONN) Parent(#COM_OWNER) Visible(False)
Define_Com Class(#POSSRCH) Name(#POSSRCH)
Mthroutine Name(uInitialize) Options(*REDEFINE)
* * In the command's uInitialize method routine, set the screen wrapper's uCommand property to #com_owner
Set Com(#POSCONN) uCommand(#com_owner)
Invoke Method(#POSSRCH.ShowForm)
Endroutine
Mthroutine Name(uExecute) Options(*REDEFINE)
Invoke Method(#Com_Ancestor.uExecute)
Invoke Method(#POSCONN.MakeRampTSAvailable)
Endroutine
Evtroutine Handling(#POSCONN.RampTSAvailable)
Invoke Method(#POSCONN.NavigateToScreen) Name('HN2000')
Endroutine
Evtroutine Handling(#POSCONN.vHandleArrive) ArrivedScreen(#CurrentScreen) PreviousScreen(#PreviousScreen) ArrivedPayload(#Payload)
Case (#CurrentScreen)
* /Debtor Search Screen
When Value_Is(= 'HN2000')
Define Field(#RETVAL) Type(*CHAR) Length(150)
Use Builtin(GET_CHAR_AREA) With_Args('*LDA' '*LIBL' "N" 0 150) To_Get(#RETVAL)
* Use Builtin(GET_CHAR_AREA) With_Args('*LDA' '*LIBL' "N" 1 30) To_Get(#RETVAL)
If Cond(#RETVAL <> '')
Use Builtin(GET_CHAR_AREA) With_Args("DA_MPY") To_Get(#COMPANY)
Use Builtin(MESSAGE_BOX_ADD) With_Args(#RETVAL)
Use Builtin(MESSAGE_BOX_ADD) With_Args(*TESTLDA)
Use Builtin(MESSAGE_BOX_SHOW)
Endif
* Use Builtin(MESSAGE_BOX_ADD) With_Args(#COMPANY)
Use Builtin(MESSAGE_BOX_SHOW)
Endcase
Endroutine
End_Com
Re: Retrieving data from the LDA
Posted: Fri Nov 10, 2023 5:17 am
by atostaine
If you want the LDA from the IBM you need to run a server function to get and return values.
Art
Re: Retrieving data from the LDA
Posted: Fri Nov 10, 2023 7:24 am
by René Houba
Hi Art,
CORRECT
That was exactly what I was thinking!!
Re: Retrieving data from the LDA
Posted: Fri Nov 10, 2023 9:26 am
by atostaine
We return the whole 1024 characters
Back and parse it on the client.
LDA is an ancient tech that was big on the SYS/36.
Re: Retrieving data from the LDA
Posted: Fri Nov 10, 2023 6:45 pm
by René Houba
So Jared,
Let's say that the LANSA function name on the IBMi is FUNC01.
1. In Windows you:
Use Builtin(CALL_SERVER_FUNCTION) With_Args('IBMi' FUNC01 'N' 'Y') To_Get(#RETCOD)
The 'Y' value in the CALL_SERVER_FUNCTION = "Receive exchange list back from server function"
2. On the IBMi in the LANSA function, you pickup the *LDA data and use the exchange command to return the value to the client environment:
Use Builtin(GET_CHAR_AREA) With_Args('*LDA' '*LIBL' "N" 0 150) To_Get(#RETVAL)
Exchange Fields(#RETVAL)
Kind regards,
René
Re: Retrieving data from the LDA
Posted: Fri Nov 10, 2023 8:40 pm
by jtaljaard
So to understand, we need to create a process on the LANSA IDE?
Re: Retrieving data from the LDA
Posted: Sat Nov 11, 2023 6:08 am
by René Houba
Correct and create in that process a LANSA function (that will be executed on the IBMi)