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