Summary -
In this topic, we described about the OUTREC Data Conversion with detailed example.
OUTREC used to convert the numeric fields from one type to another type.
Syntax -
OUTREC FIELDS=(starting position of field1, length of field1, field1 source format, TO=field1 target format,LENGTH=n,….. )
name | Description |
---|---|
Starting position of field1 | Specifies field1 starting position in the input file after sorting. |
Length of feild1 | Field1 physical length in input file. |
Field1 Source format | Specifies the field1 source format |
TO=field1 target format | Specifies the field1 target format |
n | Specifies the field1 target format length |
The below are the list of numeric formats -
- BI format for the field if want to test for binary format(‘0’, ‘1’ every bit).
- FS format for the field if want to test for character numeric ('0'-'9' inevery byte).
- ZD format for the field if want to test for zoned decimal numeric ('0'-'9'in all non-sign bytes; X'F0'-X'F9', X'D0'-X'D9' or X'C0'-X'C9' in the sign byte).
- PD format for the field if want to test for packed decimal numeric (0-9for all digits; F, D or C for the sign).
Example -
Convert the first five byte ZD to FS in the input file.
Input File: MTHUSER.SORT.INPUT01 - FB file of 80 length
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8 ********************************* Top of Data ********************************** 00001 student1 dept1 560 00003 student3 dept2 520 00004 student4 dept1 540 00005 student5 dept2 500 00002 student2 dept3 510 ******************************** Bottom of Data ********************************
Job:
000100 //Jobcard 000400 //* 000500 //********************************************************************** 000600 //* 000700 //* SORT FOR OUTREC STATEMENT 000800 //* 000900 //********************************************************************** 001100 //STEP01 EXEC PGM=SORT 001300 //SORTIN DD DSN=MTHUSER.SORT.INPUT01,DISP=SHR 001800 //SORTOUT DD SYSOUT=* 001900 //SYSOUT DD SYSOUT=* 002400 //SYSIN DD * 002411 SORT FIELDS=(1,5,CH,A) 002420 OUTREC FIELDS=(1,5,ZD,TO=FS,LENGTH=6,X,6,73) 003400 /* ****** **************************** Bottom of Data ****************************
Output:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8 ********************************* TOP OF DATA ********************************** 1 student1 dept1 560 2 student2 dept3 510 3 student3 dept2 520 4 student4 dept1 540 5 student5 dept2 500 ******************************** BOTTOM OF DATA ********************************
Explaining Solution:
- OUTREC FIELDS=(1,5,ZD,TO=FS,LENGTH=6,..) converts the first five bytes ZD from input file to FS of 6 bytes and writes it to output.
- 7th byte will be placed as a space in output file.
- OUTREC FIELDS=(..,6,73) copies the input file data from 6th byte to the output file from 8th byte onwards as it is.