Monday, July 13, 2020

SB37 abend in JCL with resolution

 SB37 abend in JCL:

The system abend code SB37 occurs, when there's not enough space or no more extents available on the current volume. 

Resolution:

Example 1:  For or below file Job got abended with SB37 then change the  current volume 

//SORTOUT  DD  DSN=RATNESH.OUTPUT.FILE
//             DISP=(NEW,CATLG,DELETE)
// *           UNIT=current_volume_name   -----> current volume which does not have enough space
//             UNIT=other_volume     -----> new volume name which will have space  


Example 2: For below file Job got abended with SB37 then change the space

//SORTOUT  DD  DSN=RATNESH.OUTPUT.FILE
//             DISP=(NEW,CATLG,DELETE)
//*            SPACE=(CYL,(5,5),RLSE,
//             SPACE=(CYL,(25,25),RLSE,
//             RECFM=FB,LRECL=250  
  





Saturday, September 28, 2019

How to Create multiple identical copies of output file for the sam input file

//STEP01   EXEC PGM=SORT                                                
//SORTIN   DD DSN=RATNESHA.SORT.INPUT01,DISP=SHR                    
//OUTPUT1  DD DSN=RATNESHA.SORT.OUTPT01,                            
//             SPACE=(CYL,(1,1),RLSE),DCB=*.SORTIN,                     
//             DISP=(NEW,CATLG,DELETE)                                  
/OUTPUT2  DD DSN=RATNESHA.SORT.OUTPT02,                            
//             SPACE=(CYL,(1,1),RLSE),DCB=*.SORTIN,                     
//             DISP=(NEW,CATLG,DELETE)                                  
//SYSOUT   DD SYSOUT=*                                                  
//SYSIN    DD *                                                         
     SORT FIELDS=COPY 
     OUTFIL FNAMES=(OUTPUT1,OUTPUT2)                                    
/* 



OUTFIL FNAMES=(OUTPUT1,OUTPUT2) 

: copies all the records to the output files OUTPUT1, OUTPUT2 to create to identical copies.

Friday, September 27, 2019

Cobol Program to Convert Gregorian Date to Julian Date For Any Input Year

IDENTIFICATION DIVISION.
PROGRAM-ID. MACJUL.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 A. 
          05 A1 PIC 9999.
          05 A2 PIC 99.
          05 A3 PIC 99.
01 B.
          05 B1 PIC 9999.
          05 B2 PIC 999.
01 C PIC 9 VALUE 2.
PROCEDURE DIVISION.
0001.
         DISPLAY "ENTER GREGORIAN DATE (YYYYMMDD):".
         ACCEPT A.
         IF A NOT NUMERIC OR A2 > 12 OR A3 > 31
         DISPLAY "INVALID DATE" GO 0001.
         MOVE A1 TO B1.
         COMPUTE B2 = A3.
         IF A2 = 12 ADD 30 TO B2 SUBTRACT 1 FROM A2.
         IF A2 = 11 ADD 31 TO B2 SUBTRACT 1 FROM A2.
         IF A2 = 10 ADD 30 TO B2 SUBTRACT 1 FROM A2.
         IF A2 = 9 ADD 31 TO B2 SUBTRACT 1 FROM A2.
         IF A2 = 8 ADD 31 TO B2 SUBTRACT 1 FROM A2.
         IF A2 = 7 ADD 30 TO B2 SUBTRACT 1 FROM A2.
         IF A2 = 6 ADD 31 TO B2 SUBTRACT 1 FROM A2.
         IF A2 = 5 ADD 30 TO B2 SUBTRACT 1 FROM A2.
         IF A2 = 4 ADD 31 TO B2 SUBTRACT 1 FROM A2.
         IF A2 = 3 ADD 28 TO B2 SUBTRACT 1 FROM A2
         DIVIDE A1 BY 4 GIVING A1 REMAINDER C
         IF C = 0 ADD 1 TO B2.
         IF A2 = 2 ADD 31 TO B2.
         DISPLAY " ".
         DISPLAY "JULION DATE IS(YYYYDDD):".
         DISPLAY B1 ":" B2.
         STOP RUN.

Thursday, September 26, 2019

JCL Limitations

Job Name Maximum Length:               008 CHARS

Accounting Information Size:               142 CHARS

Program Name Length:                        020 CHARS

JCL Procedure Limit:                            255 Statements

No. of EXEC Statements in a JOB:      255

Symbolic Parameter Length:                100 CHARS

Step Name Length:                               008 CHARS

DPRTY Maximum Value:                      015

Perform Parameter Max Value:            999

Return Code Max Value:                      4095

Time parameter Max Value:                 1439,59

Max Bloc Size:                                     32,760 Bytes

Max Record Length:                            150

Max No of Buffers Per Data Set:         255

Data Set Name Length:                       44

Output Message Limits:                      16,777,215

Concatenated Data Sets:                    255

Max no of Instream Proc in a Job:      15

GDG Member Limit:                            255

Sunday, September 22, 2019

How to find if a GDG BASE does not have any generation

//STEP01 EXEC PGM=IDCAMS              
//SYSPRINT DD DUMMY                   
//SYSOUT DD SYSOUT=*                  
//SYSIN DD *                          
 LISTCAT LEVEL(‘TEST.GDG.NAME’)     
/* 


We can use IDCAMS to check whether any GDG base is empty or any generations exist under a GDG base. LISTCAT is used to find all the properties of a GDG and in the job also this can be used along with defined word LEVEL to find the generations under a GDG base.

IDCAMS job returns ZERO as return code if any generations exist and the return code will be 04 if NO generations exist. 

By checking the return code in the next step,we can decide whether the GDG has any generations or not and subsequent action can be taken accordingly.



Recovery of Deleted Tape data set (Using Volume Serial)

You might face an issue where the TAPE data set get deleted, but the VOLUME SERIAL allocated to that data set still showing the same data set in any of the TAPE utilities you have (Like TMS – TAPE MANAGEMENT SYSTEM). 

Now you know the TAPE data set is having the same Data set that got deleted (And you are not able to find in 3.4). In this scenario, you can make use of below JCL to recover the dataset to a different data set.

Deleted TAPE DSN: HLQ1.HLQ2.DELTED.TAPE

Recovered TAPE DSN: HLQ1.HLQ2.COPIED.TAPE

//STEP01  EXEC PGM=SORT
//SORTIN   DD DSN=HLQ1.HLQ2.DELTED.TAPE,DISP=OLD,
//            UNIT=TAPE,VOL=SER=123456
//SORTOUT  DD DSN=HLQ1.HLQ2.COPIED.TAPE,
//            DISP=(,CATLG,CATLG),UNIT=TAPE,
//            DCB=(RECFM=FB,LRECL=80,BLKSIZE=0)
//SYSOUT   DD SYSOUT=*
//SYSIN    DD *
  SORT FIELDS=COPY
/*

Copy DCB of Input file to output file

In a JCL step, you want your output file DCB parameters to be same as input file. Assume you are not aware of DCB of input file, how do you achieve getting the output file DCB same as input file.

This feature is called REFERBACK.

Output file DCB can be any of the following

1. DCB=*.INPUT

Please note that the input file DD name is input. so you should ensure you give correct DDNAME.

2. DCB=YOUR.INPUT.FILE

Provide name of the input file

3. LIKE=YOUR.INPUT.FILE

Provide name of the input file

4. If your input file is in other step, you can use

DCB=(*.STEPNAME.DDNAME)

CONCATENANTION OF GDG VERSIONS USING BASE NAME – GDGORDER

If your GDG base has 3 versions, and you want to concatenate all the 3 versions and use as input to a program in JCL, instead of mentioning all the 3 version names, you could just mention the GDG base name and the JCL would use all the versions in LIFO (Last In First Out) order

Suppose you have a GDG File (YOUR.GDG.FILE) has 2 versions as below.

YOUR.GDG.FILE.V01
YOUR.GDG.FILE.V02
YOUR.GDG.FILE.V03

To user all the versions with LIFO, you can either mention as below

//INPUT DD DSN=YOUR.GDG.FILE

Or as below

//INPUT DD DSN=YOUR.GDG.FILE.V03
// DD DSN=YOUR.GDG.FILE.V02
// DD DSN=YOUR.GDG.FILE.V01

IBM has introduced a new parameter GDGORDER in which you can mention the order of versions when using just the BASE.

//INPUT DD DSN=YOUR.GDG.FILE,GDGORDER=LIFO

Above is the default parameter

Sometime you want read the first version of the GDG first and then with other versions in increasing order. In this case, you can define as below.

//INPUT DD DSN=YOUR.GDG.FILE,GDGORDER=FIFO

Above code is similar to below  code

//INPUT DD DSN=YOUR.GDG.FILE.V01
// DD DSN=YOUR.GDG.FILE.V02
// DD DSN=YOUR.GDG.FILE.V03

How to add Header and Trailer with Date, Time and Count through JCL

Header : A Name along with the current System date
Trailer  : A static message along with number of input records count

//***************************************************************
//* ADDING HEADER AND TRAILER ALONG WITH COUNTS AND DATES
//***************************************************************
//STEP01 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=A
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=TTR.SORT.TEST.IN,DISP=SHR
//SORTOUT DD DSN=TTR.SORT.TEST.OT,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,SPACE=(CYL,(5,5)),
// DCB=(RECFM=FB,LRECL=50,BLKSIZE=5000)
//*
//SYSIN DD *
  SORT FIELDS=COPY
  OUTFIL REMOVECC,
  HEADER1=(1:'CARD DETAILS AS ON',20:DATE=(MD4/),'@',TIME),
  TRAILER1=(1:'TOTAL NUM OF RECORDS:',COUNT=(M11,LENGTH=4))
/*


output

1 ----+----1----+----2----+----3----+----4--
2 CARD DETAILS AS ON 07/23/2019@05:32:39
3 001990828GOLD CREDIT3395
4 002990829GOLD DEBIT 3396
5 003990830SILVRCREDIT3396
6 004990831PLTNMDEBIT 3395
7 005990832SILVRDEBIT 3395
8 TOTAL NUM OF RECORDS:0005

Header1: It has a Static message which start from 1st position followed by a date and Time. Here given ‘@’ just to separate date and time. You can give anything here.

Trailer1: Count gives the records count excluding Header and Trailer with length of 4.

MD4/: Is a Date format with ‘/’ as a separator. There are few other date formats as well that can be used here.

M11: This is an Edit mask pattern which gives the numbers in 0005 format if the value is 5. Means it shows the leading zeroes as well. There are many other Patterns which we can use here, but as an example I have used M11.

REMOVECC: It removes the ANSI carriage control character from the Output file.




How to reverse the file records through JCL

Write the output file in reverse order of input. If the input file has some records in Random order ( not in sorted order) and if the out file needs to be written exactly in reverse order. This can be achieved by using the SORT Overlay along with OUTREC Build.

//JOBSRT1 JOB MSGLEVEL=(1,1),MSGCLASS=X //*************************************************************** //* REVERESE FILE CONTENTS BY ADDING SEQ. NUM //*************************************************************** //STEP01 EXEC PGM=SORT //SYSPRINT DD SYSOUT=A //SYSOUT DD SYSOUT=* //SORTIN DD DSN=RATNESH.TEST.RNDM.FILE,DISP=SHR //SORTOUT DD DSN=RATNESH.TCEST.RVRSE.FILE,
// DISP=(NEW,CATLG,DELETE), // UNIT=SYSDA,SPACE=(CYL,(5,5)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=8000) //* //SYSIN DD * INREC OVERLAY=(40:SEQNUM,3,ZD) SORT FIELDS=(40,3,CH,D) OUTREC BUILD=(1,35) /*



Input:

2RAGHAV RAJ PUNE LEAD 
1MAHENDER REDDY HYDERABAD DEVELOPER
4VISHU CHENNAI MANAGER 
3SHREYANSHREDDY MUMBAI ARCHITECT

Output:

3SHREYANSHREDDY MUMBAI ARCHITECT 
4VISHU CHENNAI MANAGER 
1MAHENDER REDDY HYDERABAD DEVELOPER 
2RAGHAV RAJ PUNE LEAD




Explanation: INREC OVERLAY statement adds a sequence in 40th position.
SORT FILEDS statement sorts the records in descending order based on the newly added sequence number.
OUTREC BUILD – As the sequence number is not required in output, this build statement copied the actual data till 35th position.

Note* How to reverse the records if there is no free space available in the input file or output file. In this case, SORT job requires a temporary data set to add the sequence number and sort then copying this temporary data set into the required output file.


Thursday, September 19, 2019

JCL program to compare two files

//SORTTOOL EXEC PGM=SORT 
//TOOLMSG DD SYSOUT=* 
//DFSMSG DD SYSOUT=* 
//SYSOUT DD SYSOUT=* 
//SORTJNF1 DD DSN=FIRST.FILENAME,DISP=SHR 
//SORTJNF2 DD      DSN=SECOND.FILENAME,DISP=SHR 

//SORTOUT DD DSN=THIRD.FILENAME,DISP=SHR 
//SYSIN DD * 
 SORT FIELDS=COPY 
 JOINKEYS FILES=F1,FIELDS=(1,10,A) 
 JOINKEYS FILES=F2,FIELDS=(1,10,A) 
 REFORMAT FIELDS=(F1:1,80) 
/* 

The key I compared starts at 1 and has length of 10 bytes.

Sunday, September 15, 2019

How to submit particular steps of another JCL using IEBEDIT

You may get a scenario where you wish to submit/execute only particular steps of a jcl and exclude 
others. Although this can be handled by using COND parameter but this would require editing
the original JCL to include COND parameter at each step and may be tedious exercise, and you 
might not have the access to change the original JCL.

The following JCL using IEBEDIT utility can be helpful in acheiving the above without 
editing the original JCL.

This would include Step name STEP010 of Jcl JOBNAM1 present in library
RATNSHG.ABC.JCLLIB


//IEBEDITA JOB (XXXXXXXX,,,,,XXXX),'       ',CLASS=T,         
//            MSGCLASS=Y,NOTIFY=&SYSUID                       
//*===========================================================
//* EXAMPLE FOR IEBEDIT UTILITY                               
//*===========================================================
//STEP001  EXEC PGM=IEBEDIT                                   
//SYSUT1   DD  DSN=RATNESHG.ABC.JCLLIB(JOBNAM1),DISP=SHR    
//SYSUT2   DD  SYSOUT=(*,INTRDR)                              
//SYSPRINT DD  SYSOUT=*                                       
//SYSIN    DD  *                                              
  EDIT TYPE=INCLUDE,STEPNAME=(STEP010)                       
/*         


Where 

RATNSEHG.ABC.JCLLIB is the Library containing the Input JCL and JOBNAM1 is the input JCL name


The other examples of SYSIN card can be


  EDIT TYPE=INCLUDE,STEPNAME=(STEP010,STEP040) - To include stepnames   
                                                                                                                     STEP10 and STEP40               
  
  EDIT TYPE=EXCLUDE,STEPNAME=(STEP040)         - To exclude stepnames STEP40