ITOZ: Converting a Number to Zoned Format

How to:

The ITOZ function converts a number in numeric format to zoned-decimal format. Although a request cannot process zoned numbers, it can write zoned fields to an extract file for use by an external program.

Syntax: How to Convert a Number to Zoned Format

ITOZ(length, in_value, output)

where:

length

Integer

Is the length of in_value in bytes. The maximum number of bytes is 15. The last byte includes the sign.

in_value

Numeric

Is the number to be converted, or the field that contains the number. The number is truncated to an integer before it is converted.

output

Alphanumeric

Is the name of the field that contains the result, or the format of the output value enclosed in single quotation marks.

Example: Converting a Number to Zoned Format

The following request creates an extract file containing employee IDs and salaries in zoned format for a COBOL program:

DEFINE FILE EMPLOYEE
ZONE_SAL/A8 = ITOZ(8, CURR_SAL, ZONE_SAL);
END
TABLE FILE EMPLOYEE
PRINT CURR_SAL ZONE_SAL BY EMP_ID
ON TABLE SAVE AS SALARIES
END

The resulting extract file is:

NUMBER OF RECORDS IN TABLE= 12 LINES= 12 
 
[EBCDIC|ALPHANUMERIC]  RECORD  NAMED  SALARIES 
FIELDNAME                                   ALIAS       FORMAT     LENGTH
EMP_ID                                      EID         A9           9 
CURR_SAL                                    CSAL        D12.2M      12 
ZONE_SAL                                                A8           8 
TOTAL                                                               29 
DCB USED WITH FILE SALARIES IS DCB=(RECFM=FB,LRECL=00029,BLKSIZE=00580)

If you remove the SAVE command and run the request, the output for an EBCDIC platform follows. The left brace in EBCDIC is hexadecimal C0; this indicates a positive sign and a final digit of 0. The capital B in EBCDIC is hexadecimal C2; this indicates a positive sign and a final digit of 2.

EMP_ID             URR_SAL  ZONE_SAL 
------            --------  -------- 
071382660       $11,000.00  0001100{
112847612       $13,200.00  0001320{
117593129       $18,480.00  0001848{
119265415        $9,500.00  0000950{
119329144       $29,700.00  0002970{
123764317       $26,862.00  0002686B 
126724188       $21,120.00  0002112{
219984371       $18,480.00  0001848{
326179357       $21,780.00  0002178{
451123478       $16,100.00  0001610{
543729165        $9,000.00  0000900{
818692173       $27,062.00 0002706B