convertUnicodeNumToNumber()

The sysLib.convertUnicodeNumToNumber() function provides EGL support for COBOL variables in the NATIONAL SIGN IS LEADING, SEPARATE format.
Variables in this format contain UNICODE characters (NATIONAL) with a leading sign character, such as the following:
15  UNICODENUMBER PIC S9(11)V9(04) USAGE NATIONAL SIGN IS LEADING, SEPARATE.

The sysLib.convertUnicodeNumToNumber() system function converts the digits of a source variable that contains UNICODE characters that are preceded by a UNICODE sign character into a numeric variable. The source can contain leading zeros for the integer part and can include trailing zeros for the fractional part.

Syntax

  sysLib.convertUnicodeNumToNumber(
    source UNICODE in,
    target SMALLINT | INT | BIGINT | DECIMAL out] )
source
A UNICODE variable that contains digits and a leading sign character.
target
Any non-floating point numeric variable.

Error conditions

If the content of the UNICODE variable is not in the proper format, the function throws a TypeConversionException. Any of the following format errors cause the exception:

Examples

  n SMALLINT;
  u UNICODE(4) = "1234";
  // function gets validation error   
  // u must have length of 6
  convertUnicodeNumToNumber(u, n); 

  n BIGINT;
  u UNICODE(20) = "-0000000001234567890";
  // function sets n to -1234567890
  convertUnicodeNumToNumber(u, n);

  n DECIMAL(31,4);
  u UNICODE(32) = "+1234567890123456789012345678901";
  // function sets n to 123456789012345678901234567.8901
  convertUnicodeNumToNumber(u, n);

  // Next line gets validation error for COBOL
  // NUM variables are limited to length 31 for COBOL
  n NUM(32,4);
  u UNICODE(33) = "+012345678901234567890123456789012";
  // for Java, function sets n to
  // 1234567890123456789012345678.9012
  convertUnicodeNumToNumber(u, n);

  n DECIMAL(8,4);
  u UNICODE(10) = "0123456789";
  // function throws TypeConversionException
  // "0" not valid sign character
  convertUnicodeNumToNumber(u, n);

Compatibility considerations

Table 1. Compatibility considerations
Platform Issue
JavaScript generation The function sysLib.convertUnicodeNumToNumber() is not supported.

Feedback