Parameter structure COBOL vs RPG

810 pts.
Tags:
COBOL
Parameters
RPGLE
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.

Answer Wiki

Thanks. We'll let you know when a new response is added.

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>

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following