Sign in

docs RPG Guide

Interlanguage Calls

Interlanguage Calls

When passing or receiving data from a program or procedure written in another language, it is important to know whether the other language supports the same parameter passing methods and the same data types as ILE RPG. RPG Parameter Passing Methods shows the different parameter passing methods allowed by ILE RPG and, where applicable, how they would be coded in the other the ILE languages. The table also includes the OPM RPG/400® compiler for comparison.

RPG Parameter Passing Methods

Table 1. Passing By Reference

Calling mechanismExample
ILE RPG – prototyperpgle D proc PR D parm 1A C CALLP proc(fld)
ILE C®rpgle void proc(char *parm); proc(&fld);
ILE COBOLrpgle CALL PROCEDURE "PROC" USING BY REFERENCE PARM
RPG – non-prototypedrpgle C CALL 'PROC' C PARM FLD
ILE CLrpgle CALL PROC (&FLD)

Table 2. Passing By Value

Calling mechanismExample
ILE RPG – prototyperpgle D proc PR D parm 1A VALUE C CALLP proc('a')
ILE Crpgle void proc(char parm); proc('a');
ILE COBOLrpgle CALL PROCEDURE "PROC" USING BY VALUE PARM
RPG – non-prototypedN/A
ILE CLN/A

Table 3. Passing By Read-Only Reference

Calling mechanismExample
ILE RPG – prototyperpgle D proc PR D parm 1A CONST C CALLP proc(fld)
ILE Crpgle void proc(const char *parm); proc(&fld);
ILE COBOLN/A1
RPG – non-prototypedN/A
ILE CLN/A

Note:

  1. Do not confuse passing by read-only reference with COBOL’s passing BY CONTENT. In RPG terms, to pass Fld1 by content, you would code:

         C                   PARM      Fld1          TEMP

    Fld1 is protected from being changed, but TEMP is not. There is no expectation that the parameter will not be changed.

For information on the data types supported by different HLLs, consult the appropriate language manual.