Pass a LIST data between Reusable Part using Application Control

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
nazirul_fitri
Posts: 21
Joined: Thu Sep 15, 2016 7:00 pm

Pass a LIST data between Reusable Part using Application Control

Post by nazirul_fitri »

Hi there,
wp1.PNG
wp1.PNG (74.24 KiB) Viewed 7630 times
As you can see in above picture, I create 2 RP. 1 is Filter RP & 2 is to display the filtered result. When the user click the button(‘JANA’), it will call a method in Application Controller RP (code below).

Code: Select all

Mthroutine Name(SelectState)

Define_Map For(*input) Class(#prim_alph) Name(#State)
Define_Map For(*input) Class(#prim_alph) Name(#Branch)
Define_Map For(*input) Class(#PRIM_NMBR) Name(#Month)
Define_Map For(*input) Class(#PRIM_NMBR) Name(#Year)

Define_Com Class(#dwhTempDashFuDisb.FindFILTER2) Name(#getList)

#getList.ExecuteAsync( #State #Branch #Month #Year )

Evtroutine Handling(#getList.Completed)

Selectlist Named(#PenKew)

Signal Event(SelectStateSuccess)

Endselect

Endroutine

Endroutine
It will return a few entries depending to the user selection during the filter. This is the result if user select NEGERI as ‘JOHOR’
wp32.png
wp32.png (126.02 KiB) Viewed 7630 times
It shows that my server routine is working well because we can see the result in the developer tool.

The problem is occur when I try to display the result in the Reusable Part no 2(in first picture). It should replace the LABEL accordingly and loop the RP depend on the result entries. I have made a signal event when the server routines completed and call the event in the RP no 2 to replace the LABEL, but it doesn’t work.

This is the code in the RP no 2. I only write a line of code just to test the outcome.

Code: Select all

evtroutine handling(#Application.SelectStateSuccess)

#Label1.Caption := #STATE_NAME + " - " #BRANCH_NAME

Endroutine
And this is the result that is used to have when we develop in VLF-One (the client expected the same in VL-Web). It is a bit easier to do something like this in VLF-One because we don’t need to worry much about the Application Control or to signalling the event.
wp5.PNG
wp5.PNG (107.78 KiB) Viewed 7630 times
I’m a bit confuse on how to pass the LIST data around from one RP to another RP. Any tips will helps a lot.

Thanks,
jyoung
Posts: 694
Joined: Thu Jan 21, 2016 6:43 am
Location: Oklahoma City, OK USA

Re: Pass a LIST data between Reusable Part using Application Control

Post by jyoung »

Hi,

You may want to look into creating an object to hold your list data, then you can pass that object around.

To create an object, create a new reusable part (type of object) and make use of the *LISTFIELDS option.

Code: Select all

* my object definition
begin_com role(*EXTENDS #PRIM_OBJT *LISTFIELDS #ListFields) 

group_by name(#ListFields) fields(#MyId #MyField)

define_pty name(Id) get(*AUTO #MyId) set(*AUTO #MyId)
define_pty name(MyField) get(*AUTO #MyField) set(*AUTO #MyField)
end_com
Note the *LISTFIELDS in the role and the #ListFields group_by.

Then you can declare an array of these objects

Code: Select all

define_com class(#PRIM_ACOL<#MyObject>) name(#DataList)
and pass that list to the ServerModule for population.

Code: Select all

#find.ExecuteAsync( #DataList )
The ServerModule just takes a list_map like you would normally have.

Now you can pass that list around to other components, just be sure to "pass by reference"

Code: Select all

mthroutine name(Load)
define_map for(*INPUT) class(#PRIM_ACOL<#MyObject>) name(#data) pass(*BY_REFERENCE)

for each(#item) in(#data)
* do something with each item
endfor
endroutine
For actual examples look at the xDemoWebPassingWorkingLists examples. (XDEMO_36 and XDEMO_37).

Hope this helps,
Joe
nazirul_fitri
Posts: 21
Joined: Thu Sep 15, 2016 7:00 pm

Re: Pass a LIST data between Reusable Part using Application Control

Post by nazirul_fitri »

Hi Joe,

Thanks for the help last week.

I have manage to past a LIST data to the second RP, but the thing is, its only display the last entry of my list to the RP. How can I loop the RP based on the entry on my list and display the data accordingly.

This is the result that i got:
filter.PNG
filter.PNG (87.14 KiB) Viewed 7582 times
This is the entry that should be in the RP :
result_filter.PNG
result_filter.PNG (111.75 KiB) Viewed 7582 times
this is what i expected:
result_filter1.PNG
result_filter1.PNG (104.07 KiB) Viewed 7582 times
You can see that the RP is looping based on the LIST entry to show the data.
jyoung
Posts: 694
Joined: Thu Jan 21, 2016 6:43 am
Location: Oklahoma City, OK USA

Re: Pass a LIST data between Reusable Part using Application Control

Post by jyoung »

Hmm, I've never had a collection start at the end of the list.
According to the docs
The FOR command can also be used to iterate over the collection contents. The items will be returned in the order they are stored in the collection.
For each(#Customer) in (#Customers)
...
Endfor
You can use First and Last to get either the first or last entry in the list.

Once the list gets populated from the server module, you may want to spin through it and output a trace message just to confirm if it is in the same order as the output'ed data from the server module.
Post Reply