JCL Sorting Program – IBM Mainframe


In this blog post I am going to present a simple sort program in JCL in IBM Mainframe. This is batch program in JCL.Your JCL would look like this for SORT.


//*---------------------------------------------------------------------
//* STEP1  : This program is for Sorting, Replace XXXX with the mainframe     
//*          user id and AAAA with the program name
//*---------------------------------------------------------------------
//XXXX JOB (YY),'SORT',CLASS=F,MSGCLASS=N,MSGLEVEL=(1,1),         
//      NOTIFY=XXXX
//*---------------------------------------------------------------------
//* STEP2  : SORT  AAAA  TO AAAA.SORTOUT
//*---------------------------------------------------------------------
//STEP2    EXEC SORT,COND=(0,NE)                                    
//SORTIN   DD DSN=XXXX.AAAA.YYYY,DISP=SHR
//SORTOUT  DD  DSN=XXXX.AAAA.YYYY.SORTOUT,DISP=(NEW,CATLG),
//         DCB=(RECFM=FB,LRECL=800,BLKSIZE=0),
//         SPACE=(TRK,3)
//SYSIN    DD *
       SORT FIELDS=(1,21,A,47,2,D),FORMAT=CH
       INCLUDE COND=(12,8,CH,EQ,C'20090210')        
                  
  END
/*




The explanation of the above program is as follows:-

1>The first statement is the job statement which identifies the beginning of  job with positional and keyword parameters.

Positional Parameter are components that are needed to code the job statement that apply to the entire job. 
They are Job Accounting information( YY in our example) and  Programmer name(SORT here).

Keyword parameter also applies for the entire job, We have used CLASS(F), MSGCLASS(N),   MSGLEVEL(1,1) and NOTIFY(XXXX) Parameters in our Sort Example.


2> The second step in the procedure is the EXEC statement named STEP2, which identifies the program SORT as the program to be run.

3> The SORTIN DD statement identifies the input data set containing data to be sorted         (XXXX.AAAA.YYYY)                   

4> The SORTOUT DD statement identifies the output data set where SORT is to place the sorted input (XXXX.AAAA.YYYY.SORTOUT)                   

5> The SYSIN DD statement provides instream instructions for the SORT program to use on the input data set




No comments:

Post a Comment