Troubleshooting
Problem
The following document will show how to convert from numeric to character without suppressing leading zeros.
Resolving The Problem
When converting from numeric to character using %CHAR, leading zeros are removed from the resulting character string. In order to avoid this, %EDITC must be used with an edit code of 'X'. The following example will illustrate this:
DMessage S 2
DChr_fld S 2
DTest1 S 2 0 INZ(01)
/free
Message = %CHAR(Test1);
Chr_fld = %EDITC(Test1:'X');
*inlr = *on;
/end-free
In the above example, the results are as follows:
Message = '1 '
Chr_fld = '01'
Caution: The following code example is provided on an unsupported, as is basis. |
DMessage S 2
DChr_fld S 2
DTest1 S 2 0 INZ(01)
/free
Message = %CHAR(Test1);
Chr_fld = %EDITC(Test1:'X');
*inlr = *on;
/end-free
In the above example, the results are as follows:
Message = '1 '
Chr_fld = '01'
[{"Type":"MASTER","Line of Business":{"code":"LOB68","label":"Power HW"},"Business Unit":{"code":"BU070","label":"IBM Infrastructure"},"Product":{"code":"SWG60","label":"IBM i"},"ARM Category":[{"code":"a8m0z0000000CHtAAM","label":"Programming ILE Languages"}],"ARM Case Number":"","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"All Versions"}]
Historical Number
513150363
Was this topic helpful?
Document Information
More support for:
IBM i
Component:
Programming ILE Languages
Software version:
All Versions
Operating system(s):
IBM i
Document number:
635009
Modified date:
07 November 2024
UID
nas8N1013238
Manage My Notification Subscriptions