Interview Questions   Tutorials   Discussions   Programs   

JCL - Explain with syntax and an example, the Inrec fields and Outrec build in sort?




1826
views
asked mar September 8, 2014 11:02 AM  

Explain with syntax and an example, the Inrec fields and Outrec build in sort?


           

1 Answers



 
answered By Mswami   0  

INREC can be used to filter or reformat the input data so that the sorting is more efficient.

INREC: Specifies how records are reformatted before they are sorted, copied, or merged. INREC is useful in case of large input file.

OUTREC: Specifies how records are reformatted after they are sorted, copied, or merged.Final output will be the same.

INREC in SORT JCL:

//SYSIN DD *                                      
    SORT FIELDS=COPY                              
    INREC FIELDS=(1:1,35,60:SEQNUM,6,ZD)          
  /*                                                
 /

/

Explanation - First 35 bytes will be copied to outputfile & sequence number will be added at 60th position in the outputfile.

In the following sort card the inrec statement will take the data from 7th pos (3 bytes) and put at positions 1st(3bytes) in the output file and take data from 56th position (4 bytes) and put at position 4th (4bytes). The soting will occur on the first 3 bytes of the output record.

INREC FIELDS=(1:7,3,4:56,4)
SORT FIELDS=(1,3,CH,A)

Example JCL is provided below.

........ 
//SETP001  EXEC PGM=SORT                                         
//SYSPRINT DD SYSOUT=*                                           
//SYSOUT   DD SYSOUT=*                                           
//SYSUDUMP DD SYSOUT=*                                           
//REPORT1  DD SYSOUT=*                                           
//SORTIN   DD DISP=SHR,DSN=USERID.ABC.INPFILE,
//SORTOUT  DD DSN=USERID.ABC.OUTFILE,
//      DISP=(,CATLG),                                           
//      SPACE=(TRK,(30,10),RLSE),                                
//      UNIT=SYSDA,                                              
//      DCB=(RECFM=FB,LRECL=80,BLKSIZE=0,DSORG=PS)               
//SORTWK01 DD  UNIT=DISK,SPACE=(CYL,(20,5),RLSE)                 
//SORTWK02 DD  UNIT=DISK,SPACE=(CYL,(20,5),RLSE)     
//SORTWK03 DD  UNIT=DISK,SPACE=(CYL,(20,5),RLSE)     
//SYSIN    DD *                                      
INREC FIELDS=(1:7,3,4:56,4)
SORT FIELDS=(1,3,CH,A)
/*                                                   
//*  

Another Example:

//STEP01     EXEC SORT, CYLNO=’200,100′,REGION=0K,CORE=MAX

//SORTIN     DD DSN=MAIN.FRAME.INPUT.FILE,DISP=SHR

//SORTOUT  DD DSN=MAIN.FRAME.SORT.FILE,DISP=(,CATLG,DELETE),DCB=(LRECL=180,RECFM=FB),

//                  SPACE=(CYL,(100,100),RLSE)

//SYSIN       DD *

 INREC BUILD=(1,10,11,6,SFF,TO=ZD,LENGTH=6,17,40,

57,13,SFF,TO=ZD,LENGTH=13,70,110)

SORT FIELDS=(1,10,A,17,10,A),FORMAT=CH

SUM FIELDS=(11,6,57,13),FORMAT=ZD

OUTREC FIELDS=(1,10,11:11,6,ZD,EDIT=(SII.IT),SIGNS=(,-),17,40,

57:57,13,ZD,EDIT=(SIIIIIIIII.IT),SIGNS=(,-),70,110)

/*
flag   
   add comment

Your answer

Join with account you already have

FF

Preview


Ready to start your tutorial with us? That's great! Send us an email and we will get back to you as soon as possible!

Alert