Reputation: 89
I called a cobol program from rpgle. I want to return a value from the cobol program to rpgle. I'm new to these and am not sure if I'm doing the right way. Can someone explain me the procedure to do this. below is the command I used in rpgle to call cobol.
callp prog(id:name);
and in cobol i used
working storage section.
linkage section.
01 newid.
01 newname.
procedure division using newid, newname.
If the values are edited in cobol, will the value newid
and newname
be automatically passed to rpg or is there any other way? how to pass the value in cobol back to rpgle.
Upvotes: 2
Views: 1014
Reputation: 4542
You have the basics right. That should be fine as long as you provide matching field definitions in both programs. In the ILE COBOL Linkage Section you need to add the definition of what your parameter names refer to. You have no PIC
or LIKE
clause.
In your ILE RPG program you will need to define a prototype for the call to your COBOL code. The parameter definitions in the prototype need to match the format of the parameters in COBOL. If you are using packed, zoned, or binary integer on one side, then you must use the same for that parm on the other.
(see http://pic.dhe.ibm.com/infocenter/iseries/v7r1m0/index.jsp?topic=%2Frzase%2Fsc092540419.htm)
For example, in RPG PROG1 you might commonly have something like:
D someID 7p 0
D someName 10a
D addInfo PR EXTPROG("PROG2")
D 7p 0
D 10a
callp addInfo (someID:someName);
// or omit the optional callp opcode
addInfo (someID:someName);
Then in COBOL PROG2 you could have something like:
working storage section.
linkage section.
01 newid pic s9(7) packed-decimal.
01 newname pic x(10).
procedure division using newid, newname.
Your simplest option at this point is to compile them both as individual programs. But it is also possible to use ILE techniques to combine your COBOL procedure into the final RPG program object. But save that for another time.
Upvotes: 4