EGL Reference Guide for iSeries

Data conversion (system words)

The data conversion system words are described in the next table.


System word/Usage Description
sysLib.convert
sysLib.convert
(target, direction, conversionTable)
Converts data between EBCDIC (host) and ASCII (workstation) formats or performs code-page conversion within a single format
sysVar.callConversionTable
sysVar.callConversionTable
Name of the conversion table used to dynamically convert data for calling remote programs, for starting remote asynchronous transactions, or for accessing remote files
sysVar.formConversionTable
sysVar.formConversionTable
Name of the conversion table used to dynamically convert data in text and print forms


Related reference
Data conversion
EGL statements
Function invocations
System words
System words in alphabetical order

sysLib.convert

The system function sysLib.convert converts data between EBCDIC (host) and ASCII (workstation) formats or performs code-page conversion within a single format. You can use sysLib.convert as the function name in a function invocation statement.



sysLib.convert syntax diagram

target
Name of the record, data item, or form that has the format you want to convert. The data is converted in place based on the item definition of the lowest-level items (items with no substructure) in the target object.

Variable-length records are converted only for the length of the current record. The length of the current record is calculated using the record's numElementsItem or is set from the record's lengthItem. A conversion error occurs and the program ends if the variable-length record ends in the middle of a numeric field or a DBCHAR character.

direction
Direction of conversion. "R" and "L" (including the quotation marks) are the only valid values. Required if conversionTable is specified; optional otherwise.
"R"
Default value. The data is assumed to be in remote format and is converted to local format.
"L"
Data is assumed to be in local format and is converted to remote format (as defined in the conversion table).
conversionTable
Data item or literal (eight characters, optional) that specifies the name of the conversion table to be used for data conversion. The default value is the conversion table associated with the national language code specified when the program was generated.

Definition considerations

You can use the linkage options part to request that automatic data conversion be generated for remote calls, to start remote asynchronous transactions, or for remote file access. Automatic conversion is always performed using the data structure defined for the argument being converted. If an argument has multiple formats, do not request automatic conversion. Instead, code the program to explicitly call sysLib.convert with redefined record declarations that correctly map the current values of the argument.

Example
Record RecordA
   record_type char(3);
   item1 char(20); 
end 
 
Record RecordB
   record_type char(3);
   item2 bigint;
   item3 decimal(7);
   item4 char(8); 
end
 
Program ProgramX type basicProgram
   myRecordA RecordA;
   myRecordB RecordB {redefines = myRecordA};
   myConvTable char(8);
 
   function main();
      myConvTable = "ELACNENU"; // conversion table for US English
      if (myRecordA.record_type = "00A")
         sysLib.convert(myRecordA, "L", myConvTable);
      else;
         sysLib.convert(myRecordB, "L", myConvTable);
      end
     call ProgramY myRecordA;
   end 
end


Related reference
Data conversion
Data conversion (system words)
sysVar.callConversionTable

sysVar.callConversionTable

The system variable sysVar.callConversionTable contains the name of the conversion table that is used to convert data when your program does the following at run time:

The conversion occurs when the data is being moved between EBCDIC-based and ASCII-based systems or between systems that use different code pages. Conversion is possible only if the linkage options part used at generation time specifies PROGRAMCONTROLLED as the value of property conversionTable in the callLink or asynchLink element. Conversion does not occur, however, if PROGRAMCONTROLLED is specified but sysVar.callConversionTable is blank.

Characteristics

The characteristics of sysVar.callConversionTable are as follows:

Primitive type
CHAR

Data length
8

Value saved across segments?
Yes

Definition considerations

You should use sysVar.callConversionTable to switch conversion tables in a program or to turn data conversion on or off in a program.

sysVar.callConversionTable is initialized to blanks. To cause conversion to occur, make sure that the linkage options part includes the value PROGRAMCONTROLLED, as described earlier, and move the name of a conversion table to the system variable. You can set sysVar.callConversionTable to an asterisk (*) to use the default conversion table for the default national language code. For Java, this setting references the default locale on the target system provided the locale is mapped to one of the languages that can be specified for the targetNLS build descriptor option. For COBOL, this setting references the default national language code you specified when you installed EGL Server for iSeries.

Conversion is performed on the system that originates the call, invocation, or file access. When you define multiple levels of a record structure, conversion is performed on the lowest level items (the items with no substructure).

You can use sysVar.callConversionTable in these ways:

A comparison of sysVar.callConversionTable with another value tests true only if the match is exact. If you initialize sysVar.callConversionTable with a lowercase value, for example, the lowercase value matches only a lowercase value.

The value that you place in sysVar.callConversionTable remains unchanged for purposes of comparison.

Example
  sysVar.callConversionTable = "ELACNENU"; 
// conversion table for US English COBOL generation


Related reference
Data conversion
Data conversion (system words)
sysLib.startTransaction
targetNLS

sysVar.formConversionTable

The system variable sysVar.formConversionTable contains the name of the conversion table that is used for bidirectional text conversion when an EGL-generated Java program acts as follows:

Characteristics

The characteristics of sysVar.formConversionTable are as follows:

Primitive type
CHAR

Data length
8

Value saved across segments?
Yes


Related reference
Bidirectional language text
Data conversion
Data conversion (system words)


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]