DFSORT OUTFIL Reformatting

DFSORT OUTFIL: Saving discards DFSORT OUTFIL: Repeating

Advertisements


OUTFIL can be used in a combination with the PARSE, BUILD, OUTREC, OVERLAY,FINDREP or IFTHEN parameters.

Different PARSE, BUILD, OUTREC, OVERLAY or IFTHEN parameters can be usedfor different OUTFIL statements.

VB data set considerations for the INREC andOUTREC statements also apply.

/, n/ and /.../ can be used in the BUILD, OUTREC, or IFTHEN BUILDparameters of the OUTFIL statement.

/, n/ and /.../ can’t be used in the OVERLAY or IFTHENOVERLAY parameters of the OUTFIL statement, or in any parameters of theINREC and OUTREC statements.

If n/ is used at the start or end of the BUILD,OUTREC or IFTHEN BUILD parameters, n blank lines are inserted.

If n/ is used inthe middle of the BUILD, OUTREC or IFTHEN BUILD parameters, n-1 blanks lines are inserted.


Syntax:

SORT FILEDS=(Starting position, length, data-format, A/D)
OUTFIL FNAMES=DDNAME1, 
	 INCLUDE/OMIT COND=(……),
	OUREC=(…………..)
OUTFIL FNAMES=DDNAME2,
	 INCLUDE/OMIT COND=(……),
	OUREC=(…………..)
…..
OUTFIL FNAMES=DDNAMEn, 
	 INCLUDE/OMIT COND=(……),
	OUREC=(…………..)

Name Description
DDNAMEnDDNAME is eight character’s name that representing the actual dataset in JCL.
INCLUDE/OMITSpecifies the INCLUDE/OMIT condition for specific OUTFIL
OUTRECSpecifies the OUREC condition for specific OUTFIL

DFSORT automatically sets the LRECL of each OUTFIL data set to the reformatted output record length.


Example: -

Create three output files like below.


dept1 records to file1 and add 2 digit sequence number from 60th byte starting from 1 and increment by 2.

dept2 records to file2 and add 2 digit sequence number from 60th byte starting from 2 and increment by 2.

records other than dept1 to file3.


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                                 
00006     student6           dept3          550                                 
00008     student8           dept1          530                                 
00007     student7           dept3          510                                 
00009     student9           dept2          520                                 
00010     student10          dept2          505                                 
******************************** Bottom of Data ********************************

Job:

000100 //Jobcard 
000400 //*                                                                     
000500 //**********************************************************************
000600 //*                                                                     
000006 //STEP01   EXEC PGM=SORT                                                
000007 //SORTIN   DD DSN=MTHUSER.SORT.INPUT01,DISP=SHR                    
000008 //OUTPUT1  DD DSN=MTHUSER.SORT.OUTPT01,                            
000009 //             SPACE=(CYL,(1,1),RLSE),DCB=*.SORTIN,                     
000010 //             DISP=(NEW,CATLG,DELETE)                                  
000011 //OUTPUT2  DD DSN=MTHUSER.SORT.OUTPT02,                            
000012 //             SPACE=(CYL,(1,1),RLSE),DCB=*.SORTIN,                     
000013 //             DISP=(NEW,CATLG,DELETE)                                  
000014 //OUTPUT3  DD DSN=MTHUSER.SORT.OUTPT03,                            
000015 //             SPACE=(CYL,(1,1),RLSE),DCB=*.SORTIN,                     
000016 //             DISP=(NEW,CATLG,DELETE)                                  
000017 //SYSOUT   DD SYSOUT=*                                                  
000018 //SYSIN    DD *                                                         
000019      SORT FIELDS=(1,5,ZD,A)                                             
000020      OUTFIL FNAMES=OUTPUT1,INCLUDE=(30,5,CH,EQ,C'dept1'),               
000021      OUTREC OVERLAY=(60:SEQNUM,2,ZD,START=1,INCR=2)                     
000022      OUTFIL FNAMES=OUTPUT2,INCLUDE=(30,5,CH,EQ,C'dept2'),               
000023      OUTREC OVERLAY=(60:SEQNUM,2,ZD,START=2,INCR=2)                     
000024      OUTFIL FNAMES=OUTPUT3,OMIT=(30,5,CH,EQ,C'dept1')                   
000025 /*                                                                      
****** **************************** Bottom of Data ****************************

Output File: MTHUSER.SORT.OUTPT01 - FB file of 80 length

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
00001     student1           dept1          560            01                   
00004     student4           dept1          540            03                   
00008     student8           dept1          530            05                   
******************************** Bottom of Data ********************************

File: MTHUSER.SORT.OUTPT02 - FB file of 80 length

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
00003     student3           dept2          520            02                   
00005     student5           dept2          500            04                   
00009     student9           dept2          520            06                   
00010     student10          dept2          505            08                   
******************************** Bottom of Data ******************************** 

File: MTHUSER.SORT.OUTPT03 - FB file of 80 length

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
00002     student2           dept3          510                                 
00003     student3           dept2          520                                 
00005     student5           dept2          500                                 
00006     student6           dept3          550                                 
00007     student7           dept3          510                                 
00009     student9           dept2          520                                 
00010     student10          dept2          505                                 
******************************** Bottom of Data ********************************

Explaining Solution:

  1. SORT FIELDS=(1,5,ZD,A) - sort all outputs in ascending order based on the ZD value from 1 to 5 positions.

  2. OUTFIL FNAMES=OUTPUT1,INCLUDE=(30,5,CH,EQ,C'dept1') - All the records marching with “dept1” from the 30th position of length 5 will be copied to output1 file.

  3. OUTFIL FNAMES=OUTPUT1,..,OUTREC OVERLAY=(60:SEQNUM,2,ZD,START=1,INCR=2) - generates the sequence number in OUTPUT1 file starts with 1 and increments by 2 every time from 60th byte of length two.

  4. OUTFIL FNAMES=OUTPUT2,INCLUDE=(30,5,CH,EQ,C'dept2') - All the records marching with “dept2” from the 30th position of length 5 will be copied to output2 file.

  5. OUTFIL FNAMES=OUTPUT2,..,OUTREC OVERLAY=(60:SEQNUM,2,ZD,START=2,INCR=2) - generates the sequence number in OUTPUT2 file starts with 2 and increments by 2 every time from 60th byte of length two.

  6. OUTFIL FNAMES=OUTPUT3,OMIT=(30,5,CH,EQ,C'dept1') - All the records marching with “dept1” from the 30th position of length 5 will be ignore and remaining all the records will be copied to output3 file.

DFSORT OUTFIL: Saving discards DFSORT OUTFIL: Repeating

Advertisements