Thursday, February 28, 2013

JCL to copy N records from the Mth record of a File


The Following jcl can be used to copy N number of Records from the Mth Column of an Input File to the Output File

//STEP020  EXEC PGM=SORT                        
//SORTIN   DD DSN=<INPUT FILE>, DISP=SHR
//SORTOUT  DD DSN=<OUTPUT FILE>,DISP=SHR
//SYSIN    DD *                                 
  SORT FIELDS=COPY,SKIPREC=50001,STOPAFT=20000
/*                        
//SYSOUT   DD SYSOUT=*    
This will Copy 20000 records starting from the 50001th Record of the input File.

JCL to stop copying records from one file to another

The Following JCL can be used to Stop the copying of records from input file to output after a specific number of records :-

//JOB CARD
//STEP010  EXEC PGM=SORT                              
//SORTIN   DD DSN=<Input file>, DISP=SHR
//SORTOUT  DD DSN=<OUTPUT FILE>,
//            DISP=SHR
//SYSIN    DD *                                       
  SORT FIELDS=COPY,STOPAFT=50000                      
/*                                                    
//SYSOUT   DD SYSOUT=*                                
//SYSUDUMP DD SYSOUT=*                                
//*                                                   
The above jcl will stop the copying after 50000 records

JCL to Extract first N number of records from a File

We can use the ENDREC parameter to get the first 1000 records from a file and copy it to another file. The Sample JCL is as follows :--

//JOBCARD
//STEP01   EXEC  PGM=SORT                                 
//SYSOUT   DD    SYSOUT=*                                 
//SYSPRINT DD    SYSOUT=*                                 
//SORTIN   DD    DSN=<INPUT FILE>,           
//         DISP=SHR                                       
//SORTOUT  DD    DSN=<OUTPUT FILE>,                  
//         DISP=SHR                                       
//SYSIN    DD    *                                         
  SORT FIELDS=COPY                                         
  OUTFIL FILES=OUT,ENDREC=1000                             
/*                                                         

We can give any value in the ENDREC field. Depending on the value, the extraction will happen from the input file.

INCLUDE CONDITION

The Include Condition serves the opposite purpose for the Omit Condition. In this case, the Data mentioned in the Include condition will only be considered for Data Sort. The Sample is as given below :-

//JOB CARD
//*                                                       
//STEP001 EXEC PGM=SYNCSORT                               
//SORTIN  DD DSN=<input File>,                 
//           DISP=SHR                                     
//SORTOUT DD DSN=<output File>,                            
//           DISP=SHR                                     
//SYSOUT DD SYSOUT=*                                      
//SYSIN  DD *                                             
  SORT FIELDS=COPY                                        
  INCLUDE COND=(01,06,CH,EQ,C'VVTEST')                    
/*                                                        
Here the check will happen from the 1st column for the next 6 bytes and will include records if the value of the same is VVTEST.

OMIT Condition

Suppose we have an input file layout as given below :-


(TITLE)        (NAME)     (DOB)
MATHS         RAM         11111991
ENGLISH      KRISH      01011990


Suppose we have to sort the above data excluding the header(TITLE). For this we can use OMIT Condition in the SORT JCL. It can be included as follows :-

//JOB CARD
//*                                                     
//STEP001 EXEC PGM=SYNCSORT                             
//SORTIN  DD DSN=<INPUT FILE NAME>,               
//           DISP=SHR                                   
//SORTOUT DD DSN=<OUTPUT FILE NAME>,            
//           DISP=SHR ( give parameters if u have not created input file)                                   
//SYSOUT DD SYSOUT=*                                    
//SYSIN  DD *                                           
  SORT FIELDS=COPY                                      
  OMIT COND=(01,01,CH,EQ,C'(')                          
/*                                                      
//*                                                

In the omit Condition, the Parameters are as follows :-

OMIT COND=(<start column>,<length of field from starting column>,CH,EQ,C'<field>')   

   

Thursday, December 30, 2010

FEW IMPORTANT THINGS IN JCL

1) Two Types of Parameters :-
POSITIONAL PARAMETERS
KEYWORD PARAMETERS
.
2) Job Statement :- Marks the Beginning of the Job. The 1st JCL Statement
//T111 111,t,class=a,msgclass=a,region=2M,notify=sysid
the above given is a sample job statement.(dnt try this stmt coz its not complete)
.
3)JobLib :- The Joblib will specify the pds or directory where the exec pgm shud chk for the file.
//joblib dd dsn=t12.exp.mmm
//exec pgm=mem1
So the program will chk for member mem1 in t12.exp.mmm
.
4) Steplib :- While Joblib is common for the entire program, STEPLIB is specific for a single step
//joblib dd dsn=t12.exp.nnn
//step exec pgm=mem
//step1 exec pgm=mem1
//steplib dd dsn=t12.exp.mmm
here the program will check for mem in t12.exp.nnn while it will check for mem1 in t12.exp.mmm... Thus Steplib will over ride Joblib for that single step.
.
5)Abend - Abnormal End
Could occur due to many reasons. It could happen if your load library is full, or your program logic is wrong, or your program might be going in an infinite loop and so on. Some Abend codes are SE37,U000 s4038, s722,s322 etc.
.
6) TIME :- Specifies the Maximum CPU Time that can be used up by a Job or allocated to a job. It will be specified along with the Job Statement.
Time=(min,sec) is the basic format. It can also be written like Time= min or Time=sec.
Time=Maximum is the limit. Limit is 357912mins ie, 248.55 days.
.
7)REGION :- Specify the amount of Storage associated with a step or a job. Can be used with a Job as well as a step. It can be in Kilobytes or MegaBytes.
//step1 exec pgm=mem1, Region=8K

Some Abbrevations in Mainframes

JCL - Job Control Language

COBOL - COmmon Business Oriented Language

CICS - Customer Information Control System

ABEND - Abnormal END

PARM - Parameter

VSAM - Virtual Storage Access Method

MVS - Multiple Virtual Storage

MVS/ESA - Enterprise System Architecture

MVS/XA - Extended Architecture