Data Type Compatibility between ILE RPG and ILE COBOL
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 1 shows the 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
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
with *NOSTDTRUNC PIC S9(4) COMP-5 |
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 |
PIC 9(4) COMP-5 | 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
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 with
*NOSTDTRUNC PIC S9(9) COMP-5 |
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 |
PIC 9(9) COMP-5 | 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
PIC S9(18) BINARY PIC S9(18) COMP-5 |
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 9(18) COMP-5 | 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. |