|
Dave There are several ways to do this, I am assuming that the structure will be passed by pointer, if not remove the BASED variable. Option 1: Use a multiple occurance data structure, remember to use the OCCURS statement to change elements. skuData DS Occurs(30) Based(skuDataBase) sku 15A num 5P 0 skuSize 15A qtyForSize 7P 0 dateForSize 8P 0 For the return code you will need to use pointers with this option, skuDataElements will have to be passed in if you are not always expecting 30 elements, otherwise you can use the %Elem(skuData) BIF in its place. returnCode 10I Based(returnCodeBase) returnCodeBase = %Addr(skuData) + skuDataElements * %Size(skuData) Option 2: Use a structures of arrays, each array can be used exactly as an array DS skuData 42A Dim(30) Based(skuDataBase) sku 15A Overlays(skuData : 1) num 5P 0 Overlays(skuData : *NEXT) skuSize 15A Overlays(skuData : *NEXT) qtyForSize 7P 0 Overlays(skuData : *NEXT) dateForSize 8P 0 Overlays(skuData : *NEXT) returnCode 10I If the return code will always be at the end of the 30 elements then the second option will produce the correct results, otherwise you will need to play with some pointers, you will also need to have the number of SKU elements passed in. returnCode 10I Based(returnCodeBase) returnCodeBase = %Addr(skuData) + skuDataElements * %Size(skuData) Duane -----Original Message----- From: Dave Murvin [mailto:davem@xxxxxxxx] Sent: Monday, August 25, 2003 9:38 PM To: rpg400-l@xxxxxxxxxxxx Subject: Arrays of Structures as a parameter in V5R1 Hi, Looking for suggestions for ways to program arrays of structures (which also have arrays) as an input parameter. Program will be called from an external Java program using pcml. Unfortunately we are on V5R1 and the project deadlines may not allow an upgrade to V5R2 before implementation. Within the RPGLE program the input structure looks something like this: SKU 15,A num1 5,0 SKU Size 1 15,A Qty for Size 1 7,0 Date for Size 1 8,0 . . . SKU Size 36 15,A Qty for Size 36 7,0 Date for Size 36 8,0 This whole structure will be repeated up to 30 times in one call to the program. There is also a return code at the end of all of this. Partial list of the proposed pcml call looks something like this: <struct name='availreply' > <data name="size" type="char" length="XX"/> <data name="availabilityQty" type="<packed or zoned>" length="XX"/> <data name'"date" type="<[acked or zoned>" length="8"/> </struct> <struct name='stylerequest' usage='inputoutput'> <data name="styleNumber" type="char" length="XX" usage='input"/> <data name="reply" type="struct" struct="availreply" usage="output" conunt="36"/> </struct> <program name="pgm1" path="/QSYS.LIB/.../pgm1.pgm"> <data name="request" type="struct" struct="Stylerequest" count="30" usage="inputoutput"/> <data name="returnCode" type="char" length="XX" usage="output"/> </program> The call will be requesting from one to 30 SKUs at a time. So far, I am not seeing any way to do this other than one huge input parm with all the fields listed individually. Perhaps a list of 30 structures, or would that be 30 parameters? Thanks for the help. Dave Murvin DRM Enterprises, Inc. _______________________________________________ This is the RPG programming on the AS400 / 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. NOTICE: This electronic mail transmission may contain confidential information and is intended only for the person(s) named. Any use, copying or disclosure by any other person is strictly prohibited. If you have received this transmission in error, please notify the sender via e-mail.
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.