The INREC control statements allow users to reformat an input record before processing. The user can
The reformatted input record Consists only of the user-specified fields in the order denoted, and are aligned on the boundaries or in the columns indicated.
You can create the reformatted INREC records in one of the following ways using unedited, edited, or converted input fields and a variety of constants:
INREC BUILD=(1,20,C'ABC',26:5C'*',15,3,PD,EDIT(TTT.TT),21,30,80:X)
INREC OVERLAY=(45:45,8,TRAN=LTOU)
INREC FINDREP=(IN=C’Mr.',OUT=C'Mister')
INREC IFTHEN=(WHEN=(1,5,CH,EQ,C'TYPE1'), BUILD=(1,40,C'**',+1,TO=PD)), IFTHEN=(WHEN=(1,5,CH,EQ,C'TYPE2'), BUILD=(1,40,+2,TO=PD,X'FFFF')), IFTHEN=(WHEN=NONE,OVERLAY=(45:C'NONE'))
INREC BUILD=(1,8,20C'*',9) OUTREC BUILD=(1,4,3Z,5) or INREC FIELDS=(1,40,45,5) OUTREC FIELDS=(1,45,C'****')
OVERLAY or IFTHEN, and FIELDS or BUILD, can differ with respect to position-only. For example:
INREC BUILD=(1,24,32:25) OUTREC IFTHEN=(WHEN=(8,1,ZD,GT,+5), BUILD=(1,24,25:C'Yes',28,10)), IFTHEN=(WHEN=NONE,BUILD=(1,24,25:C'No ',28,10)) or: INREC FIELDS=(1,18,8C'*',23) OUTREC OVERLAY=(24:C'A')
Example 1:
//DFSPARM DD * OPTION COPY,NOSZERO /* //SYSIN DD * INREC IFTHEN=(WHEN=(1,2,FS,EQ,+0),OVERLAY=(22:C'Yes')), IFTHEN=(WHEN=NONE,OVERLAY=(22:C'No ')) /*
Example 2:
//SYSIN DD * OPTION COPY,NOSZERO INREC IFTHEN=(WHEN=(1,2,FS,EQ,+0),OVERLAY=(28:C'A')), IFTHEN=(WHEN=NONE,OVERLAY=(28:C'B')) /*
In this example, three fixed-length input files are sorted and reformatted for output. Unnecessary fields are eliminated from the output records.
The input record size is 80 bytes, with three records per block. The INCLUDE control statement includes or excludes records while the SUM control statement sums them. Reformatted input records are fixed-length; record size is 23 bytes.
INCLUDE COND=(5,1,GE,C'M'),FORMAT=CH INREC FIELDS=(10,3,20,8,33,11,5,1) SORT FIELDS=(4,8,CH,A,1,3,FI,A),WORK=1,FILES=3 SUM FIELDS=(17,4,BI) RECORD TYPE=F,LENGTH=80 INPFIL BLKSIZE=240 OUTFIL BLKSIZE=230
Output:
For INREC, the INCLUDE COND operands must refer to the fields of the original input records: The OUTFIL indicates the 23-byte records are written as ten records per block in the output file.
INCLUDE COND=(5,1,GE,C'M'),FORMAT=CH OUTREC FIELDS=(10,3,20,8,33,11,5,1) SORT FIELDS=(20,8,CH,A,10,3,FI,A) SUM FIELDS=(38,4,BI)
Identical results are achieved with INREC or OUTREC. However, the use of OUTREC makes it easier to code the SORT and SUM statements. In either case, the INCLUDE COND parameters must refer to the fields of the original input records. However, with INREC, the SUM, and SORT FIELDS parameters must refer to the fields of the reformatted input records, while with OUTREC, the SUM and SORT FIELDS parameters must refer to the fields of the original input records.
This example shows how the overflow of a summary field can be prevented when three fixed-length files are sorted and reformatted for output. The input record size is 80 bytes.
INREC FIELDS=(1,35,2Z,36,45) SORT FIELDS=(20,4,CH,D,10,3,CH,D),WORK=1,FILES=3 SUM FIELDS=(36,4,BI,40,8,PD) RECORD TYPE=F,LENGTH=80 INPFIL BLKSIZE=240 OUTFIL BLKSIZE=246
Output:
SORT and SUM statements must refer to fields of the reformatted input records.
Reformatted output records are identical to reformatted input records.
To prevent overflow of the summary field, the two-byte summary field at positions 36 and 37 in the original input records expands to a four-byte summary field in positions 36 through 39 of the reformatted input/output record before sorting.
The OUTFIL maintains the three records per block but with a record length of 82 instead of 80.
Note: Do not use this method with negative FI summary fields as padding with zeros rather than ones changes the sign.
This example illustrates how the overflow of a summary field can be prevented when three fixed-length data sets are merged and reformatted for output. The input record size is 80 bytes. To illustrate the use of the RECORD statement, assume that SORTIN and SORTOUT are not present (that is, all input/output is handled by user exits).
INREC FIELDS=(1,35,2Z,36,45) MERGE FIELDS=(20,4,CH,D,10,3,CH,D),FILES=3 SUM FIELDS=(36,4,BI,40,8,PD) RECORD TYPE=F,LENGTH=(80,,82)
The reformatted input records are fixed-length with a record size of 82 bytes (an insignificant increase from the original size of 80 bytes). They look as follows:
The MERGE and SUM statements must refer to the fields of the reformatted input records. The reformatted output records are identical to the reformatted input records.
Thus, the 2-byte summary field at positions 36 and 37 in the original input records expands to a 4-byte summary field in positions 36 through 39 of the reformatted input/output record before merging. This prevents overflow of this summary field.
Restriction: If OUTREC were used instead of INREC, the records would be reformatted after merging, and the 2-byte summary field might overflow.
This example illustrates how a fixed-length input data set can be sorted and reformatted for output. A more efficient sort is achieved by using INREC before sorting to reduce the input records as much as possible, and using OUTREC after sorting to add padding, the current date, and repeated fields. The SORTIN LRECL is 80 bytes.
INREC BUILD=(20,4,12,3) SORT FIELDS=(1,4,D,5,3,D),FORMAT=CH OUTREC BUILD=(5X,1,4,H,19:1,2,5,3,DATE1(-),80X'FF')
The reformatted input records are fixed-length and have a record size of seven bytes (a significant reduction from the original size of 80 bytes). They look as follows:
The SORT and OUTREC statements must refer to the fields of the reformatted input records.
The reformatted output records are fixed lengths with a record size of 113 bytes. SOLRF (the IBM-supplied default) is in effect, so unless the SORTOUT LRECL is specified or available, it will automatically be set to the reformatted record length of 113. The reformatted output records look as follows:
Thus, the use of INREC and OUTREC allows sorting of 7-byte records rather than 80-byte records, even though the output records are 113 bytes long.
This example illustrates how a sequence number can be generated, how values in one numeric or date format can be converted to another format, and how a lookup table can be used.
OPTION COPY,Y2PAST=1985 INREC FIELDS=(SEQNUM,4,BI, 8,5,ZD,TO=PD, 31,2,PD,TO=FI,LENGTH=2, 15,6,Y2TP,25,3, CHANGE=(1,C'L92',X'01',C'M72',X'02',C'J42',X'03'), NOMATCH=(X’FF'))
The reformatted input records will look as follows:
The SORT statement can now refer to the “sort” field in the reformatted input records. The OUTREC statement is used to restore the records to their original format.
Example 6
This example illustrates how you can use the OVERLAY parameter with INREC and OUTREC to change certain columns in your records without affecting other columns.
INREC OVERLAY=(61:21,11,SFF,ADD,41,11,SFF,TO=PD,LENGTH=5) SORT FIELDS=(61,5,PD,A) OUTREC OVERLAY=(61:61,5,PD,EDIT=(SIII,IIT.TT),SIGNS=(+,-))
Example 7
This example illustrates how you can use IFTHEN clauses with INREC to reformat different records in different ways. IFOUTLEN=57 is used to set the reformatted record length to 57.
OPTION COPY INREC IFTHEN=(WHEN=(5,2,CH,EQ,C'GP',AND,2,1,BI,EQ,+1), BUILD=(1,6,16,20,C'T1',X'0003',1,7,20C'1')), IFTHEN=(WHEN=(5,2,CH,EQ,C'GP',AND,2,1,BI,EQ,+2), BUILD=(1,6,45,20,C'T2',X'0008',16,7,20C'2')), IFTHEN=(WHEN=(5,2,CH,EQ,C'GP',AND,2,1,BI,EQ,+3), BUILD=(1,6,31,20,C'T3',X'0005',25,7,20C'3')), IFTHEN=(WHEN=NONE,OVERLAY=(27:C'00',X'FFFF')), IFOUTLEN=57
Records with ‘GP’ in positions 5-6 and X’01’ in position 2 are reformatted as follows:
Records with ‘GP’ in positions 5-6 and X’02’ in position 2 are reformatted as follows:
Records with ‘GP’ in positions 5-6 and X’03’ in position 2 are reformatted as follows:
Records without ‘GP’ in positions 5-6 or without X’01’, X’02’, or X’03’ in position 2 are reformatted as follows:
Example 8
This example illustrates how you can left-justify characters in an input field so they can be sorted without regard to the leading blanks.
INREC OVERLAY=(16:1,15,JFY=(SHIFT=LEFT)) SORT FIELDS=(16,15,CH,A) OUTREC BUILD=(1,15) Input: CARRIE VICKY FRANK SAM DAVID MARTIN Output: CARRIE DAVID FRANK MARTIN SAM VICKY
If we wanted the output to contain the sorted left-justified fields, we could use these control statements:
INREC BUILD=(1,15,JFY=(SHIFT=LEFT)) SORT FIELDS=(1,15,CH,A) Output: CARRIE DAVID FRANK MARTIN SAM VICKY
Example 9
This example illustrates how you can sort FB input records with variable position/length fields, such as comma-separated values.
INREC PARSE=(%00=(ENDBEFR=C',',FIXLEN=11), %01=(ENDBEFR=C',',FIXLEN=5), %02=(FIXLEN=6)), OVERLAY=(31:%00,42:%01,47:%02) SORT FIELDS=(31,11,CH,A,42,5,UFF,A,47,6,SFF,D) OUTREC BUILD=(1,30) Input: Marketing,96218,+27365 Development,3807,+1275 Research,7283,+5001 Output: Development,3807,+1275 Marketing,96218,+27365 Research,7283,+5001
Example 10
This example illustrates how you can sort VB input records with variable position/length fields, such as comma-separated values. This example is very similar to the previous example for FB records, except that with VB records we need to copy the fixed parsed fields after the 4-byte RDW rather than at the end of the records.
INREC PARSE=(%00=(ENDBEFR=C',',FIXLEN=11), %01=(ENDBEFR=C',',FIXLEN=5), %02=(FIXLEN=6)), BUILD=(1,4,5:%00,16:%01,21:%02,27:5) SORT FIELDS=(5,11,CH,A,16,5,UFF,A,21,6,SFF,D) OUTREC BUILD=(1,4,27) Input: Length|Data 26|Marketing,96218,+27365 26|Development,3807,+1275 23|Research,7283,+5001 Output: Length|Data 26|Development,3807,+1275 26|Marketing,96218,+27365 23|Research,7283,+5001
Example 11
This example illustrates how you can remove characters from FB or VB records.
OPTION COPY INREC FINDREP=(IN=(X’00’,X'FF'),OUT=C'') Input: RDW----|Data 000F0000D1E4D5C500C1D7D9C9D3FF 00100000C2C5E3E3E800C4C1C9E2E8FF Output: RDW----|Data 000D0000D1E4D5C5C1D7D9C9D3 000E0000C2C5E3E3E8C4C1C9E2E8
Note that the X’00’ and X’FF’ characters have been removed and the RDW length decreased accordingly. For VB input records, FINDREP processing automatically starts at position 5 after the RDW so the X’00’ characters in the RDW are not affected.
Example 12
This example illustrates how you can find a value in FB or VB records and overlay it with a larger value without shifting other bytes in the records.
OPTION COPY INREC FINDREP=(IN=C'BALANCE', OUT=C'BALANCE 1000',SHIFT=NO,DO=1) Input: CUSTOMER1 10100 MNTHLY STMT BALANCE 2000 CUSTOMER2 11100 Output: CUSTOMER1 10100 MNTHLY STMT BALANCE 1000 CUSTOMER2 11100
Example 13
This example illustrates how you can SORT and INCLUDE groups of FB records depending on a value in the first record of each group. We propagate the value in the first record of the group to every record of the group, SORT and INCLUDE on the value, and then remove it.
INREC IFTHEN=(WHEN=GROUP,BEGIN=(2,4,CH,EQ,C'RPT.'),PUSH=(31:6,8)) OPTION EQUALS SORT FIELDS=(31,8,CH,A) OUTFIL INCLUDE=(31,8,CH,EQ,C'FRANK',OR, 31,8,CH,EQ,C’SRIHARI’),BUILD=(1,30) Input: 1RPT.SRIHARI LINE 1 FOR REPORT 1 LINE 2 FOR REPORT 1 ... 1RPT.VICKY LINE 1 FOR REPORT 2 LINE 2 FOR REPORT 2 Output: 1RPT.SRIHARI LINE 1 FOR REPORT 1 LINE 2 FOR REPORT 1 ...
Example 14
This example illustrates how to convert a mmddyy date to a ccyyddd date and a 3-character weekday string, and how to convert a ccyyddd date to a ccyy/mm/dd date and 1-digit weekday string.
OPTION COPY,Y2PAST=1996 INREC BUILD=(1,6,Y2W,TOJUL=Y4T,X, 1,6,Y2W,WEEKDAY=CHAR3,X, 9,7,Y4T,TOGREG=Y4T(/),X, 9,7,Y4T,WEEKDAY=DIGIT1) Input: 120409 1999014 051895 2003235 999999 0000000 013099 1992343 Output: 2009338 FRI 1999/01/14 5 2095138 WED 2003/08/23 7 9999999 999 0000/00/00 0 1999030 SAT 1992/12/08 3
The Y2PAST=1996 option sets the century window to 1996-2095. The century window is used to transform yy in the Y2W field to ccyy.
Note: Date conversion is not performed for the special indicators (all 9s and all 0s); the special indicator is just used appropriately for the output date field.
Example 15
This example illustrates how you can add and subtract days, months, and years from date fields.
OPTION COPY INREC OVERLAY=(11:1,8,Y4T,ADDDAYS,+50,TOGREG=Y4T, 21:1,8,Y4T,SUBMONS,+7,TOGREG=Y4T, 31:1,8,Y4T,ADDYEARS,+2,TOGREG=Y4T) OUTFIL REMOVECC, HEADER1=('Input +50 days -7 months +2 years') Input: 20070305 20071213 20080219 20080901 20091122 20090115 20100915 20100630 99999999
Processing:
Output: Input +50 days -7 months +2 years 20070305 20070424 20060805 20090305 20071213 20080201 20070513 20091213 20080219 20080409 20070719 20100219 20080901 20081021 20080201 20100901 20091122 20100111 20090422 20111122 20090115 20090306 20080615 20110115 20100915 20101104 20100215 20120915 20100630 20100819 20091130 20120630 99999999 99999999 99999999 99999999
Note: ‘99999999’ input value is treated as a special indicator for output.
A well-maintained product backlog is crucial for successful product development. It serves as a single…
Incremental value to the customer refers to the gradual delivery of small, functional parts of…
A Product Market refers to the group of potential customers who might be interested in…
The Professional Agile Leadership - Evidence-Based Management (PAL-EBM) certification offered by Scrum.org is designed for…
The Professional Agile Leadership (PAL I) certification, offered by Scrum.org, is designed to equip leaders…
Choosing the right Scrum Master Certification depends on your current experience and career goals. If…