Alphanumeric and national strings are transferred to JCI functions in structures which contain a length field in addition to the data area.
Example:
01 ANUM. 05 ANUM-LEN PIC S9(9) COMP-5 VALUE 10. 05 ANUM-TEXT PIC X(10) VALUE "ANUM-TEXT". 01 NAT. 05 NAT-LEN PIC S9(9) COMP-5 VALUE 10. 05 NAT-TEXT PIC N(10) VALUE N"NAT-TEXT".
In this chapter, such structures in the formats are referred to as Cobvar
or CobNvar
.
Whether blanks at the end of the text area are ignored or retained depends on the function called. In some functions this behavior can be controlled by means of an additional parameter.
Alphanumeric characters and COBOL strings have an EBCDIC representation, while the Java VM expects or supplies a UTF representation (depending on the interface, UTF8 or UTF16). Necessary conversions are performed automatically in the JCI functions. For this purpose, it must be possible to represent all characters in EDF03IRV. National characters (strings) (UTF16 representation) must be used for characters (strings) for which no such representation exists, otherwise the result is undefined. National strings must also be used for strings which contain binary zeros. Only convertible characters may be used for interfaces for which no national strings are defined (e.g. class and method names).
Java strings are available as objects. Conversion between Java strings and COBOL strings takes place automatically in the JCI functions.
Conversion consists of two partial steps:
Conversion between EBCDIC strings and UTF8 strings (for alphanumeric strings only).
Conversion between UTF8 and UTF16 strings and objects.
If an error occurs in any of these conversions (e.g. lack of memory), the condition variable ResErrCode
(COPY element JCI-METHODRES) is set to the value RES-ERR-NOMEM
(error in the first step) or RES-ERR-OBJECT
(error in the second step).
If the length field of the COBOL structure is equal to 0 before the conversion, the text area remains unchanged when a Java string is converted to a COBOL string. In the case of conversion in the other direction, an object is created for a null string. If the length field is less than 0 before the conversion, the condition variable ResErrCode
is set to RES-ERR-LENGTH
.