Data conversion

Because of differences in how data is interpreted in different runtime environments, your program may need to convert the data that passes from one environment to another. Data moving from Java™ environments to COBOL environments, and from COBOL to Java, always need data conversion. Data conversion in IBM® Rational® EGL Community Edition occurs at Java run time.

Programs supporting bidirectional languages such as Arabic or Hebrew can use bidi conversion tables to specify the reordering of text data in addition to code page conversion. See the topic "Bidirectional language text" for information on creating bidi conversion tables.

Your service uses a conversion table in the following run time situations:
You might use runtime conversion in the following situations:
The next sections provide the following details:

Data conversion at run time in generated Java code

The following rules pertain to Java code:
  • When a generated Java service calls a generated Java service or program, conversion occurs in the caller, in accordance with a set of EGL classes initiated at run time. In most cases no conversion at all is needed, even if the caller is accessing a remote platform that uses a code page that is different from the code page used by the invoker. However, you must specify a conversion table in the following situation:
    • The caller is Java code and is on a system that supports one code page
    • The called code is a non-Java logic and is on a system that supports another code page

    The table name in this case is a symbol that indicates the kind of conversion that is required at run time.

  • When a generated Java service accesses a remote WebSphere® MQ message queue, conversion occurs in the caller, in accordance with a set of EGL classes started at run time. If the caller is accessing a remote platform that uses a code page that is different from the code page used by the invoker, specify a conversion table in the association element that refers to the WebSphere MQ message queue.
The next table lists the conversion tables that generated Java code can access at run time. Each name has the format CSOcx. Variables are explained in the following list:
c
This variable represents the character set supported on the called program's platform. Select one of these:
  • J for Java (if the called program is an EGL-generated Java program)
  • E for EBCDIC (if the called program is an EGL-generated COBOL program)
x
This variable represents the code page number for the specified language on the remote program's platform. Each number is specified in the Character Data Representation Architecture Reference and Registry, SC09-2190. The registry identifies the coded character sets supported by the conversion tables.

  Remote Platforms
Language Linux® UNIX® Windows® 2000/NT/XP z/OS UNIX System Services or iSeries® Java z/OS or iSeries COBOL
Arabic CSOJ1046 CSOJ1046 CSOJ1256 CSOJ420 CSOE420
Chinese, simplified CSOJ1381 CSOJ1381 CSOJ1386 CSOJ1388 CSOE1388
Chinese, traditional CSOJ950 CSOJ950 CSOJ950 CSOJ1371 CSOE1371
Cyrillic CSOJ866 CSOJ866 CSOJ1251 CSOJ1025 CSOE1025
Danish CSOJ850 CSOJ850 CSOJ850 CSOJ277 CSOE277
Eastern European CSOJ852 CSOJ852 CSOJ1250 CSOJ870 CSOE870
English (UK) CSOJ850 CSOJ850 CSOJ1252 CSOJ285 CSOE285
English (US) CSOJ850 CSOJ850 CSOJ1252 CSOJ037 CSOE037
French CSOJ850 CSOJ850 CSOJ1252 CSOJ297 CSOE297
German CSOJ850 CSOJ850 CSOJ1252 CSOJ273 CSOE273
Hebrew CSOJ856 CSOJ856 CSOJ1255 CSOJ424 CSOE424
Japanese CSOJ943 CSOJ943 CSOJ943 CSOJ1390 (Katakana SBCS), CSOJ1399 (Latin SBCS) CSOE1390 (Katakana SBCS), CSOE1399 (Latin SBCS)
Korean CSOJ1363 CSOJ1363 CSOJ1363 CSOJ1364 CSOE1364
Portuguese CSOJ850 CSOJ850 CSOJ1252 CSOJ037 CSOE037
Spanish CSOJ850 CSOJ850 CSOJ1252 CSOJ284 CSOE284
Swedish CSOJ850 CSOJ850 CSOJ1252 CSOJ278 CSOE278
Swiss German CSOJ850 CSOJ850 CSOJ1252 CSOJ500 CSOE500
Turkish CSOJ920 CSOJ920 CSOJ1254 CSOJ1026 CSOE1026

When you are calling a program from Java, if you do not specify a value for the conversion table in the linkage options part, the default conversion tables are those for English (US).

Conversion algorithm

Data conversion of records and structures is based on the declarations of the structure fields that do not have a substructure.

No conversion is performed for variables that have no name (indicated by an asterisk in a structured record), or for variables of type BIN, BIGINT, BOOLEAN, INT, SMALLINT, DECIMAL, MONEY, PACF, HEX, STRING, or UNICODE. However, if you are using a bidirectional conversion table, UNICODE and STRING variables will be reversed as defined in the table. For more information, see Working with bidirectional data.

Data of type CHAR, DBCHAR, or MBCHAR is converted in accordance with the COBOL or Java conversion tables.

For variables of type FLOAT and SMALLFLOAT, the conversion routine converts from Java to zSeries® COBOL and back using the IEEE 754 format for Java and the IBM 370 format for zSeries COBOL. No conversion is necessary for FLOAT and SMALLFLOAT variables between Java and iSeries COBOL.

On EBCDIC-to-ASCII conversion for MBCHAR data, the conversion routine deletes shift-out/shift-in (SO/SI) characters and inserts an equivalent number of blanks at the end of the variable. On ASCII-to-EBCDIC conversion, the conversion routine inserts SO/SI characters around double-byte strings and truncates the value at the last valid character that can fit in the field. If the MBCHAR field is in a variable length record and the current record end is in the MBCHAR field, the record length is adjusted to reflect the insertion or deletion of SO/SI characters. The record length indicates where the current record ends.

For variables of type NUM or NUMC items, the conversion routine converts all but the last byte using the CHAR algorithm. The sign half-byte, which is the first half-byte of the last byte in the field, is converted according to the hexadecimal values shown in the next table.
Table 1. Conversion for NUM and NUMC variables
EBCDIC for type NUM EBCDIC for type NUMC ASCII
F (positive sign) C 3
D (negative sign) D 7

For variables of type DATE, INTERVAL, TIME, or TIMESTAMP, EGL converts the values using the CHAR algorithm and the string form of the variable.

You can find more information on the sysLib.convert() system function and the sysVar.callConversionTable system variable in the topics "convert()" and "callConversionTable."


Feedback