convertUnsignedUnicodeNumToNumber()

This function provides EGL support for COBOL variables in unsigned format, as a complement to sysLib.convertUnicodeNumToNumber().

This sysLib.convertUnsignedUnicodeNumToNumber() system function converts the digits of a source variable (containing UNICODE characters and no 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. No decimal character is included.

Syntax

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

Error conditions

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

Examples

  n1 smallInt;
  u1 unicode(4) = "1234";
  //convertUnsignedUnicodeNumToNumber(u1, n1);  
  // ==>Validation error.. u must have length of 5

  n2 smallInt;
  u2 unicode(6) = "+01234";
  convertUnicodeNumToNumber(u2, n2);  // ==> 1234

  n3 smallInt;
  u3 unicode(5) = "01234";
  convertUnsignedUnicodeNumToNumber(u3, n3);  // ==> 1234

  n4 smallInt;
  u4 unicode(5) = "-1234";
  try
    convertUnsignedUnicodeNumToNumber(u4, n4);  
    // ==> Type conversion exception, - not decimal digit 
  onException(ex AnyException)
    SysLib.writeStdout(ex.message);
  end
  
  n5 int;
  u5 unicode(11) = "+0123456789";
  convertUnicodeNumToNumber(u5, n5);  // ==> 123456789

  n6 int;
  u6 unicode(10) = "0123456789";
  convertUnsignedUnicodeNumToNumber(u6, n6);  // ==> 123456789

  n7 bigInt;
  u7 unicode(20) = "-0000000001234567890";
  convertUnicodeNumToNumber(u7, n7);  // ==> -1234567890

  n8 bigInt;
  u8 unicode(19) = "0000000001234567890";
  convertUnsignedUnicodeNumToNumber(u8, n8);  // ==> 1234567890

  n9 bin(18, 9);
  u9 unicode(19) = "0000123456123400000";
  convertUnsignedUnicodeNumToNumber(u9, n9);  
  // ==> 123456.123400000

  n10 decimal(31, 4);
  u10 unicode(32) = "+1234567890123456789012345678901";
  convertUnicodeNumToNumber(u10, n10);  
  // ==> 123456789012345678901234567.8901

  n11 decimal(31, 4);
  u11 unicode(31) = "1234567890123456789012345678901";
  convertUnsignedUnicodeNumToNumber(u11, n11);  
  // ==> 123456789012345678901234567.8901

  n12 num(32, 4);  
  // ==> Validation error for COBOL environments, 
  //which do not support 32 digit numbers
  u12 unicode(33) = "+01234567890123456789012345678901";
  convertUnicodeNumToNumber(u12, n12);  
  // ==> 1234567890123456789012345678.901 for Java environments

  n13 num(32, 4);  // ==> Validation error for COBOL environments, 
  //which do not support 32 digit numbers
  u13 unicode(32) = "012345678901234567890123456789012";
  convertUnsignedUnicodeNumToNumber(u13, n13);  
  // ==> 1234567890123456789012345678.9012 for Java environments

  n14 decimal(8, 4);
  u14 unicode(9) = "01234.123";
  try
    convertUnsignedUnicodeNumToNumber(u14, n14);  
    // ==> TypeConversionException, "." not valid numeric character
  onException (ex AnyException)
    SysLib.writeStdout(ex.message);
  end
  
  n15 decimal(8, 4);
  u15 unicode(9) = "01234123 ";
  try
    convertUnsignedUnicodeNumToNumber(u15, n15);  
    // ==> TypeConversionException, " " (blank at end) 
    //not valid numeric character
  onException (ex AnyException)
    SysLib.writeStdout(ex.message);
  end

Compatibility considerations

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

Feedback