You can pass data to a called ILE RPG program or procedure by using CALL...BY REFERENCE, CALL...BY VALUE, or CALL...BY CONTENT. Refer to Passing Data Using CALL...BY REFERENCE, BY VALUE, or BY CONTENT for a description of how to use CALL...BY REFERENCE, CALL...BY VALUE or CALL...BY CONTENT.
When data is passed to the ILE RPG program using CALL...BY REFERENCE, a pointer to the data item is placed into the argument list that is accepted by the ILE RPG program. When data is passed to the ILE RPG program using CALL...BY CONTENT, the value of the data item is copied to a temporary location and then a pointer containing the address of the copy's temporary location is placed into the argument list that is accepted by the ILE RPG program. For CALL...BY VALUE, the value of the item is placed into the argument list that is accepted by the ILE RPG program. CALL...BY VALUE can be used to call ILE RPG procedures but not ILE RPG program objects.
In your ILE COBOL program, you describe the arguments that you want to pass to the ILE RPG program or procedure, in the Data Division in the same manner as you describe other data items in the Data Division. Refer to Passing and Sharing Data Between Programs for a description of how to describe the arguments that you want to pass.
In the called ILE RPG program, you describe the parameters that you want to receive from the ILE COBOL program using the PARM operation. Each receiving parameter is defined in a separate PARM operation. You specify the name of the parameter in the Result field. The Factor 1 and Factor 2 entries are optional and indicate variables or literals. The value from the Factor 1 field is transferred from the Result field entry when the call occurs. The value from the Factor 2 field is placed in the Result field entry upon return.
Another method of defining parameters in an ILE RPG program is to specify them in a prototype. Each parameter is defined on a separate definition specification. For parameters passed BY REFERENCE, no special keywords are necessary. For parameters passed BY VALUE, the VALUE keyword is used. Refer to the WebSphere Development Studio: ILE RPG Programmer's Guide for more information on how to describe the arguments in an ILE RPG program.
ILE RPG and ILE COBOL have different data types. When you want to pass data between programs written in ILE RPG and ILE COBOL, you must be aware of these differences. Some data types in ILE RPG and ILE COBOL have no direct equivalent in the other language.
Table 18 shows the ILE COBOL data type compatibility with ILE
RPG.
Table 18. ILE COBOL Data Type Compatibility with ILE RPG
ILE COBOL | ILE RPG I-Spec, D-Spec, or C-Spec | Length | Description |
---|---|---|---|
PIC X(n). | blank or A in data type column, n in length column, and blank in decimal position column | n | A character field where n=1 to 32 767 |
PIC 1 INDIC .. | *INxxxx | 1 | An indicator. |
PIC S9(n) DISPLAY | S in data type column or blank in data type column, n in length column, and 0 in decimal position column | n | A zoned decimal. |
PIC S9(n-p)V9(p) COMP-3 | P in data type column, n in length column, and p in decimal position column | n/2 + 1 | A packed decimal. |
PIC S9(n-p)V9(p) PACKED-DECIMAL. | P in data type column, n in length column, and p in decimal position column | n/2 + 1 | A packed decimal. |
Not supported | I in data type column, 3 in length column, and 0 in decimal position column | 1 | A 1-byte signed integer with a range of -128 to 127 |
Not supported | U in data type column, 3 in length column, and 0 in decimal position column | 1 | A 1-byte unsigned integer with a range of 0 to 255 |
PIC S9(4) COMP-4. | B in data type column, 4 in length column, and 0 in decimal position column | 2 | A 2-byte signed integer with a range of -9999 to +9999. |
PIC S9(4) BINARY. | B in data type column, 4 in length column, and 0 in decimal position column | 2 | A 2-byte signed integer with a range of -9999 to +9999. |
PIC S9(4) BINARY. *NOSTDTRUNC option | I in data type column, 5 in length column, and 0 in decimal position column | 2 | A 2-byte signed integer with a range of -32768 to 32767 |
Not supported | U in data type column, 5 in length column, and 0 in decimal position column | 2 | A 2-byte unsigned integer with a range of 0 to 65535 |
PIC S9(9) COMP-4. | B in data type column, 9 in length column, and 0 in decimal position column | 4 | A 4-byte signed integer with a range of -999999999 to +999999999. |
PIC S9(9) BINARY. | B in data type column, 9 in length column, and 0 in decimal position column | 4 | A 4-byte signed integer with a range of -999999999 to +999999999. |
PIC S9(9) BINARY. *NOSTDTRUNC option | I in data type column, 10 in length column, and 0 in decimal position column | 4 | A 4-byte signed integer with a range of -2147483648 to 2147483647 |
Not supported | U in data type column, 10 in length column, and 0 in decimal position column | 4 | A 4-byte unsigned integer with a range of 0 to 4294967295 |
PIC S9(18) COMP-4. | I in data type column, 20 in length column, and 0 in decimal position column | 8 | An 8-byte signed integer with a range of -9223372036854775808 to 9223372036854775807. |
PIC S9(18) BINARY. | I in data type column, 20 in length column, and 0 in decimal position column | 8 | An 8-byte signed integer with a range of -9223372036854775808 to 9223372036854775807. |
Not supported | U in data type column, 20 in length column, and 0 in decimal position column | 8 | An 8-byte unsigned integer with a range of 0 to 18446744073709551615. |
USAGE IS COMP-1 | F in data type column, 4 in length column | 4 | A 4-byte internal floating-point field. |
USAGE IS COMP-2 | F in data type column, 8 in length column. | 8 | An 8-byte internal floating-point field. |
05 VL-FIELD. 10 i PIC S9(4) COMP-4. 10 data PIC X(n). | A in data type column, n in length column. Keyword VARYING. | n+2 | A variable length field where i is the intended length and n is the maximum length. |
05 n PIC 9(9) COMP-4. 05 x redefines n PIC X(4). | U in data type column, 4 in length column. To manipulate move to unsigned field in data structure overlaid by character array and use bit operations on each byte. | 4 | Bitfields can be manipulated using hex literals. |
01 record 05 field1... 05 field2... | data structure | n | A structure. Structures passed should be passed as a pointer to the structure if you want to change the contents of the structure. |
USAGE IS POINTER | * in data type column | 16 | A pointer. |
PROCEDURE-POINTER | * in data type column and keyword PROCPTR | 16 | A 16-byte pointer to a procedure. |
USAGE IS INDEX | I in data type column, length is 10, 0 in decimal position | 4 | A 4-byte integer. |
REDEFINES | data structure subfield | n | An element of a union. |
OCCURS | Keyword OCCURS or keyword DIM | n*(length of data_type) | An array. |
FORMAT DATE | D in data type column | n | A date data type. |
FORMAT TIME | T in data type column | n | A time data type. |
FORMAT TIMESTAMP | Z in data type column | n | A timestamp data type. |
PIC G(n) | G in data type column | n*2 | A graphic (double-byte) data type. |
Not supported | C in data type column | n*2 | A UCS-2 (Universal Character Set) data type. |
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.