× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



In the current version that I've, the caller will do below to walk the
link list that returned from the service program:
D myFamily ds
likeds(cumGetCustomerFamilyTree_Cust)
D based(myFamily_p)
D myFamilyHead ds
likeds(cumGetCustomerFamilyTree_Cust)
D based(myFamilyHead_p)

// call the export procedure to build/get the link list
myFamilyHead_p = cumGetCustomerFamilyTree(myCuNo);

// loop thru the link list
myFamily_p = myFamilyHead_p;
dow myFamily_p <> *null;
doSomthingWithThisFamilyMember(myFamily.number :myFamily.level);
myFamily_p = myFamily.next;
enddo;

// call the export procedure to destroy the link list
cumDestroyCustomerFamilyTree(myFamilyHead_p);



In the encapsulated version, I envision caller needs to do this:
// create a list
myFamilyID = cumBuildCustomerFamilyTree(myCuNo);

//loop thru the list
myRetCode = cumSetCustomerFamilyTree(myFamilyID: 'FIRST');
dow myRetCode > 0;
doSomthingWithThisFamilyMember(
cumGetCurrentFamilyMember_Number(myFamilyID)
:cumGetCurrentFamilyMember_Level(myFamilyID));
cumSetCustomerFamilyTree('Next');
enddo;

// call the export procedure to destroy the link list
cumDestroyCustomerFamilyTree(myFamilyID);


You are right that the encapsulated version is better, but the
complexity of creating this service program is conflicting with my
project due date :). Tough choice.



-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Alan Campin
Sent: Wednesday, March 12, 2008 12:29 PM
To: rpg400-l@xxxxxxxxxxxx
Subject: Re: link list returned from service program

<snip>
Encapsulation is a good thing.

Indeed. As a general rule, return a pointer to the program to the
structure which is managed by the service program itself (i.e. allocated
and destroyed).
The program only knows about the pointer, it knows nothing about the
internal structure. Then pass this pointer as the first argument to
procedures "GetNextCustomer", "GetParentCustomer". And if you put all
the code like this that belongs to the Customer entity into one
well-named serviceprogram then we even have a bit of OO here.
</snip>

<clip>

The downside to service programs, if you would call it that, is that
they take a lot of work to create. It is more difficult to create a
general purpose service program than a single purpose program but the
results are almost always worth it.

</clip>

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.