Object Inheritance and Data Loading

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
jyoung
Posts: 642
Joined: Thu Jan 21, 2016 6:43 am
Location: Oklahoma City, OK USA

Object Inheritance and Data Loading

Post by jyoung » Thu Dec 29, 2016 7:53 am

I have to Reusable Part Objects, MOBClient and MOBClientStatistic. MOBClientStatistic inherits from MOBClient.

Code: Select all

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

group_by name(#ListFields) fields(#CLOFID #CLOCN #CLOFN #CLOD)

define_pty name(OfficeId) get(*AUTO #CLOFID) set(*AUTO #CLOFID)
define_pty name(ControlNumber) get(*AUTO #CLOCN) set(*AUTO #CLOCN)
define_pty name(DepartmentCode) get(*AUTO #CLOD) set(*AUTO #CLOD)
define_pty name(Caption) get(*AUTO #CLOFN) set(*AUTO #CLOFN)

end_com

Code: Select all

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

group_by name(#ListFields) fields(#wk_TotalSales #wk_GrossMargin #wk_TotalHoursWorked #wk_EmployeeCount #wk_GrossMarginPercent #wk_GrossMarginPerHour #wk_AverageHoursWorked #wk_PercentOfSales #wk_PercentOfGrossMargin)

define_pty name(TotalSales) get(*AUTO #wk_TotalSales) set(*AUTO #wk_TotalSales)
define_pty name(GrossMargin) get(*AUTO #wk_GrossMargin) set(*AUTO #wk_GrossMargin)
define_pty name(TotalHours) get(*AUTO #wk_TotalHoursWorked) set(*AUTO #wk_TotalHoursWorked)
define_pty name(EmployeeCount) get(*AUTO #wk_EmployeeCount) set(*AUTO #wk_EmployeeCount)
define_pty name(GrossMarginPercent) get(*AUTO #wk_GrossMarginPercent) set(*AUTO #wk_GrossMarginPercent)
define_pty name(GrossMarginPerHour) get(*AUTO #wk_GrossMarginPerHour) set(*AUTO #wk_GrossMarginPerHour)
define_pty name(AverageHoursWorked) get(*AUTO #wk_AverageHoursWorked) set(*AUTO #wk_AverageHoursWorked)
define_pty name(PercentOfSales) get(*AUTO #wk_PercentOfSales) set(*AUTO #wk_PercentOfSales)
define_pty name(PercentOfGrossMargin) get(*AUTO #wk_PercentOfGrossMargin) set(*AUTO #wk_PercentOfGrossMargin)
end_com
I get a list of MOBClientStatistics from the ServerModule and the data coming down is correct, it has the MOBClient and MOBClientStatistic data in it.
(censored client names)
Capture.PNG
Capture.PNG (26.68 KiB) Viewed 1188 times
However when iterating through the data on the client, the base class data is not populated in the object.
Capture2.PNG
Capture2.PNG (11.34 KiB) Viewed 1188 times

Code: Select all

#SYS_APPLN.TraceMessageText( ("GetClients Completed Found &1 Records").Substitute( #ClientStatisticsList.ItemCount.AsString ) )

for each(#client) in(#ClientStatisticsList)
#SYS_APPLN.TraceMessageText( ("Client Name:&1").Substitute( #client.Caption ) )
endfor
Am I doing something wrong?

dannyoorburg
Posts: 152
Joined: Mon Jan 04, 2016 9:50 am
Location: Australia

Re: Object Inheritance and Data Loading

Post by dannyoorburg » Thu Dec 29, 2016 8:45 am

Hi,

Fields in Visual Lansa don't play nicely with inheritance. They never have.

If you were to use a field like #STD_TEXT in RDMLX in both your component AND its ancestor, you'll find it's actually 2 different fields, each with their own value.

The listfield mapping will only look at the fields used in whatever class the object is created as, not the fields out of its ancestors. You can probably argue thats incorrect (take it up with support if you want), but in the greater scheme of fields not playing a role in the OO side of Visual Lansa it's at least consistent...

Cheers,
Danny

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

Re: Object Inheritance and Data Loading

Post by jyoung » Thu Dec 29, 2016 9:38 am

I was afraid of that, but as you said, at least its consistent.

Thanks for the help.

Post Reply