Structures are used to transfer arguments and result values between the COBOL program and JCI functions which call Java methods or edit Java data fields. These must contain all the necessary information. The structures are defined in the COPY elements JCI-METHODARGS and JCI-METHODRES (see sections "JCI-METHODARGS - Function arguments" and "JCI-METHODRES - Function result"). In this chapter they are referred to as MethodArg or MethodRes.
If nothing else is defined in the function descriptions, the following prerequisites apply for calling functions which reference an argument of the type MethodArg or MethodRes:
Arguments
Before the function is called, the
CallArgNumfield must contain the number of arguments to be transferred.For each argument, an element of the
CallArgtable must be supplied with values in the structure.In the
ArgTypefield, the condition nameARG-...which corresponds to the COBOL data type must be set.The address of aCobvarorCobNvarstructure must be specified for strings. If trailing spaces are to be ignored,IGNORE-TRAILING-SPACESmust also be set. Other arguments must be transferred directly into the structure.Result values
For result values, the condition name which corresponds to the COBOL data type
RES-...must be set in theResTypefield, orRES-VOIDif no return value is expected. If a string is expected as the return value, the address of aCobvarorCobNvarstructure must be specified with a maximum length for the data area in theResValAddrfield. If the length<=0, the result value is not transferred.After returning from the function, a
CobvarorCobNvarstructure referenced as a return value contains the number of transferred characters (maximum entry value) in the length field, and the transferred characters in the data area. For other data types, the return value is transferred directly into the structure.
If an exceptional situation occurred during the conversion of a floating point data field or string object, the ResErrCode field contains the corresponding error code after returning from the function. This can be inquired by means of the condition variable RES-ERR-<condition> (see sections "Characters and strings" and "Floating point numbers"). If an argument was incorrect (RETURN-CODE RET-ERR-EARGUMENT), the ResErrIndex field contains the number of the argument.
The table below provides an overview of the definitions and the corresponding COBOL and Java types. For COBOL types whose name begins with 'JCI-', a type definition exists in the COPY element JCI-TYPEDEF. A '*' in the last column specifies that automatic conversion of the argument or result value will take place in the JCI functions.
Java type | COBOL type | Variable | Condition name | |
String | Structure | Addr | ANUM-STRING | * |
byte | JCI-byte | Byte | BYTE | |
char | PIC X | Achar | ANUM-CHAR | * |
char | PIC N | Nchar | NAT-CHAR | |
boolean | JCI-boolean | Boolean | BOOLEAN | |
short | JCI-short | Short | SHORT | |
int | JCI-int | Int | INT | |
long | JCI-long | Long | LONG | |
float | USAGE COMP-1 | Float | FLOAT | * |
double | USAGE COMP-2 | Double | DOUBLE | * |
Java object (also string object) | JCI-object | Object | OBJECT |