810 pts.
 Parameter structure COBOL vs RPG
We have a COBOL program which can select up to 42 lines. The parameter structure is: 01 PARM PIC X(1024). 03 ID PIC X(4). 03 SELECTED OCCURS 42. 05 ITEM PIC X(4). 05 DESCRPT PIC x(20). I need to call this pgm in RPG. How do I best define the parameters without defining each individual field.

Software/Hardware used:
ASKED: June 24, 2008  1:52 PM
UPDATED: June 27, 2008  6:49 AM

Answer Wiki:
There is a nice trick in RPGIV to define this sort of parallel array. Your parameters, in RPG, would be like this : <pre> C *Entry Plist C Parm p_ID C Parm p_Selected </pre> In the D-specs, parameter p_Selected would be declared like this: <pre> D p_Selected DS D aSelected 24 Dim(42) D aItem 4 OverLay(aSelected:1) D aDescript 20 OverLay(aSelected:5) </pre> In the RPG program, there are now THREE arrays. aSelected is 42 elements of 24 characters, aItem is 42 elements of 4 characters, being the first four characters from EACH element of aSelected, and aDescript, being 42 elements of 20 characters, being the last 20 characters of EACH element of aSelected. For anyone else reading this answer - you can use these linked arrays to perform sorts. If you sort on aDescript, then aItem is sorted too, to keep the values together - very useful! Regards Sloopy Thanks Sloopy, You got me on the right track. I Solved it this way: <pre> D PParm DS 1024 D Id 1 4 D Array 5 1012 D PSelected DS D PArr 24 Dim(42) D Item 4 Overlay(PArr:1) D Slec 20 Overlay(PArr:5) C Call 'COBOL01' C Parm PParm C Eval PSelected = Array </pre>
Last Wiki Answer Submitted:  June 27, 2008  6:49 am  by  r.otto   810 pts.
All Answer Wiki Contributors:  r.otto   810 pts. , Sloopy   2,195 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _