The NumToZoned procedure dynamically converts numeric data stored in a character field to zoned (signed) decimal data, then converts that zoned decimal to character. Unlike a traditional assignment statement such as MOVE or EVAL, NumToZoned works with packed and integer (binary) data that is extracted from a flat file using %subst or similar functions. The data passed to NumToZoned must be in valid packed decimal or binary format that is stored in a character field.
The primary difference between this procedure and NumToChar is that you have a choice of edit codes and return formats with NumToChar, where as NumToZoned provides a quick method for returning a character form of a numeric value without applying edit characteristics. The return value includes all leading zeros.
varying-length-char-value NumToZoned( szSrcValue 256A Const Varying : DataType 1A Const : nSrcLen 5I 0 Const : nSrcDec 5I 0 Const OPTIONS(*NOPASS) |
| Symbolic Named Constant | Value |
| T_Signed or T_Integer | X'00' |
| T_Zoned | X'02' |
| T_Packed | X'03' |
If the function succeeds, the return value is the character form of the numeric value specified on the szSrcValue parameter. The value is returned as zoned decimal stored in a varying length character field. This value may be assigned to a character field (with or without the varying attribute).
If the function fails, the return value is empty.
This procedure is provided for dynamic conversion only. It provides a quick method to convert data stored in a buffer to zoned decimal with leading zeros included. It is used for by the CSV and XML routines.