Passing Lists

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
User avatar
lawingo
Posts: 50
Joined: Fri Dec 04, 2015 6:41 am

Passing Lists

Post by lawingo » Fri Sep 28, 2018 5:26 am

Is there a limitation in defining a RP in a Server Module? For Instance I want to create a reference to a List Object

Code: Select all

Define_Com Class(#PRIM_ACOL<#dwlg_do>) Name(#gUserList) Reference(*DYNAMIC)
However i'm getting the error: "PRIM_ACOL<dwlg_DO> is only supported on the web." DWLG_DO Target Platform is "Web Browser"

Thanks

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

Re: Passing Lists

Post by jyoung » Fri Sep 28, 2018 5:34 am

You should be able to set the object's (DWLG_DO) target platform to "All Platforms" and be able to use it on the client and server.

Joe

User avatar
lawingo
Posts: 50
Joined: Fri Dec 04, 2015 6:41 am

Re: Passing Lists

Post by lawingo » Fri Sep 28, 2018 5:39 am

Ha! Thanks. That worked. Well that makes a lot of sense!

Best,
Chad

User avatar
lawingo
Posts: 50
Joined: Fri Dec 04, 2015 6:41 am

Re: Passing Lists

Post by lawingo » Fri Sep 28, 2018 6:23 am

Maybe I spoke to soon.... Can anyone post an example of a Reusable Part Executing a Server Module and passing a List?

Now in my RP it doesn't recognize the list map. It says: "Method Execute does not contain parameter name List."

Server Module:

Code: Select all

Define_Com Class(#PRIM_ACOL<#dwlg_do>) Name(#gUserList)
Field_Map For(*INPUT) Field(#DWLGID) Parameter_Name(id)
List_Map For(*OUTPUT) List(#gUserList) Parameter_Name(List)
RP:

Code: Select all

#GetDetail.Execute Id(#miLoginID) List(#moUserList)
Thanks
Chad

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

Re: Passing Lists

Post by jyoung » Fri Sep 28, 2018 6:45 am

As far as I know you can't pass a component (PRIM_ACOL) from a server module but you can pass a component with *LISTFIELDS to a servermodule for output.

Example RP (notice the *LISTFIELDS and group_by):

Code: Select all

function options(*DIRECT)
begin_com role(*EXTENDS #PRIM_OBJT *LISTFIELDS #ListFields)

group_by name(#ListFields) fields(#JCTC #wk_Packed #TCTCD #wk_OfficeNumber #wk_ControlNumber #wk_Department #wk_CountryCode #wk_StartDate #wk_EndDate #wk_JobType)

define_pty name(TransactionCode) get(*AUTO #JCTC) set(*AUTO #JCTC)
define_pty name(TransactionAmount) get(*AUTO #wk_Packed) set(*AUTO #wk_Packed)
define_pty name(TransactionDescription) get(*AUTO #TCTCD) set(*AUTO #TCTCD)

* extra data we need to carry with us
define_pty name(OfficeNumber) get(*AUTO #wk_OfficeNumber) set(*AUTO #wk_OfficeNumber)
define_pty name(ControlNumber) get(*AUTO #wk_ControlNumber) set(*AUTO #wk_ControlNumber)
define_pty name(Department) get(*AUTO #wk_Department) set(*AUTO #wk_Department)
define_pty name(CountryCode) get(*AUTO #wk_CountryCode) set(*AUTO #wk_CountryCode)
define_pty name(StartDate) get(*AUTO #wk_StartDate) set(*AUTO #wk_StartDate)
define_pty name(EndDate) get(*AUTO #wk_EndDate) set(*AUTO #wk_EndDate)
define_pty name(JobType) get(*AUTO #wk_JobType) set(*AUTO #wk_JobType)
end_com
You server module then has to specify list with the same fields. Just like you normally would passing lists.

Code: Select all

def_list name(#Transactions) fields(#JCTC #wk_Packed #TCTCD #wk_OfficeNumber #wk_ControlNumber #wk_Department #wk_CountryCode #wk_StartDate #wk_EndDate #wk_JobType) type(*WORKING) entrys(*MAX)
srvroutine name(Get) session(*REQUIRED)
list_map for(*OUTPUT) list(#Transactions) parameter_name(TransactionList)
field_map for(*OUTPUT) field(#wk_Status) parameter_name(Status)

#wk_Status := ER

 *do work

#wk_Status := OK
endroutine
You use it on the client, then you pass your PRIM_ACOL of your object as the output list

Code: Select all

define_com class(#PRIM_ACOL<#CMGCBDInstanceListItem>) name(#ListItems)

#Get.Execute status(#wk_Status) transactionlist(#ListItems)
Now on the client when the server module returns, you have a populated PRIM_ACOL instead of a LIST.

The runtime seems smart enough to map an OUTPUT List on the Server to a PRIM_COL on client, but you can't pass the PRIM_COL directly. AFAIK.

Hope this helps,
Joe

Post Reply