|
On Aug 14, 2017, at 3:50 AM, Joni V. <joni_vanderheijden@xxxxxxxxxxx> wrote:
Hello everyone,
I was setting up an interface to an other system, and had a little RPG issue.
I had an interface passing data based on a datastructure which can contain arrays. For example:
Dcl-Ds tInterfaceDs Template Qualified;
NbElements Zoned(3);
LsElements LikeDs(tElementDs) Dim(10);
SwImportant Ind;
End-Ds;
Now in RPG, even if only 3 elements are filled in the array, the space for the empty elements will be reserved. The value of SwImportant will be positioned after the 10 elements. So the address of the switch is at: address datastructure + size(NbElements) + 10 * size(LsElements)
On the other side of the interface they have dynamic list types. So when only 3 elements are filled they only expect 3 elements. They value of the switch is expected after the 3 elements. So the address of the switch is at: address datastructure + size(NbElements) + 3 * size(LsElements)
This interface is still being used for other systems, and they had a component which mapped each list to a dynamic list (in COBOL). This component could not be added to our architecture.
For most interfaces, we differentiated between the two interfaces (the old system and the new system without the mapping).
When there was only one list, I moved it to the end of the datastructure, since it doesn't trigger issues if the empty elements are at the end of the data being passed.
But if there was more than one list in a certain datastructure, we had to resort to mapping the data to the correct position by manipulating their address pointers. This works great, but lowers readability a lot.
This whole approach seemed a bit forced, and I got the feeling that there should be a better approach. How would you have approached this issue?
Are there any plans for dynamic arrays, allowing variables in the Dim keyword like they do for COBOL in OCCURS ... DEPENDING ON?
Thanks in advance,
Joni
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related questions.
Help support midrange.com by shopping at amazon.com with our affiliate link: http://amzn.to/2dEadiD
As an Amazon Associate we earn from qualifying purchases.
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.