Showing posts with label Mainframe Tips & Tricks. Show all posts
Showing posts with label Mainframe Tips & Tricks. Show all posts

Friday, 15 February 2019

Removing duplicates from VB file


Consider I have a VB file of length 321 bytes (4 for RDW + 317 actual length) and wanted to remove duplicate records from a file.

Here is the sample JCL: 

//REMODUPL   EXEC PGM=SORT                                     
//SORTIN   DD DSN=INPFILE1,DISP=SHR                 
//SYSIN    DD *                                                
  OPTION VLSHRT                                                
  SORT FIELDS=(5,317,CH,A)                                     
  SUM FIELDS=NONE                                              
/*                                                             
//SORTOUT  DD DSN=OUTFILE1,DISP=(NEW,CATLG,DELETE),           
//         RECFM=VB,LRECL=321,AVGREC=K
//SYSOUT   DD SYSOUT=* 

VLSHRT tells DFSORT to temporarily replace any missing control field bytes with binary zeros.

For eg.       

As you are aware that VB file will have records of different lengths and the maximum length of the record in the VB file will be treated as LRECL of that VB file.

During the sort say i have two records one with length 300 and another with 317, then the record with 300 bytes will be temporarily replaced with extra 17 binary zeros (300+17 binary zeros) to run the sort smoothly.  These binary zeros are temporary and will NOT be copied to output dataset. 

The default OPTION is NOVLSHRT (reverse of VLSHRT) which terminates the sort if it finds shorter record than the one specified in SORT FIELDS.          

Tuesday, 9 February 2016

Copying PDS members to PS file


  • Open the PDS
  • In the command line, type save <name1> 
  • Now you can see all the members saved in PS file                          USERID.<name1>.MEMBERS


You can use this file to export the members to excel.

Monday, 14 September 2015

How to specify VSAM dataset as dummy in JCL ?

There will be a situation where we need to dummy our VSAM dataset. Here is how we can do that..

//VSAMFLNM  DD DUMMY, AMP='AMORG'

AMP='AMORG'  - This parameter tells the OS to treat the file as VSAM file.

Monday, 24 August 2015

How to create a temporary VSAM file

We know how to create a normal temporary sequential file and how to use it.

Let us find out on how we can create temporary VSAM file.

//TEMPFILE  DD  DSN=&&TEMPFILE,DISP=(NEW,PASS,DELETE),
//              UNIT=SYSDA,
//              SPACE=(80,(5,2)),
//              AVGREC=U/K/M
//              RECORG=KS/ES/RR/LS
//              KEYLEN=8,KEYOFF=0


First parameter of SPACE is always numeric and assumes it as a BLKSIZE

AVGREC will have either Units, Kilos or Megabytes

RECORG (Record Organization) such as KSDS,ESDS, RRDS and LDS

KEYLEN specifies the key length

KEYOFF specifies the offset

Thursday, 20 August 2015

How to Submit Job Automatically After Current Job

We can use IEBGENER to write the Job into internal reader (INTRDR) as the last step in the current job as below:

       //LASTSTEP PGM=IEBGENER
   //SYSOUT   DD SYSOUT=*
   //SYSPRNT  DD SYSOUT=*
   //SYSIN    DD DUMMY
   //SYSUT1   DD DSN=YOUR.BATCH.JCL(JOBNAME),DISP=SHR
   //SYSUT2   DD SYSOUT=(A,INTRDR)

Reading a Sequential File in Reverse Order

There are two ways to read the sequential file in reverse order

     1. Using FileAid

//STEP0100 EXEC PGM=FILEAID                   
//SYSPRINT DD SYSOUT=*                        
//DD01     DD DSN=YOUR INPUT DATASET,DISP=SHR
//DD01O    DD DSN=YOUR OUTPUT FILE IN REVERSE ORDER,
//         DISP=(NEW,CATLG,DELETE),UNIT=SYSDA,
//         SPACE=(CYL,(X,Y),RLSE)
//SYSIN    DD  *
 $$DD01 COPYBACK
/*                        

2. Using SORT (Assuming LRECL of input file is 80 bytes)

//STEP0100 EXEC PGM=SORT                   
//SYSOUT   DD SYSOUT=*                        
//SORTIN   DD DSN=YOUR INPUT DATASET,DISP=SHR
//SORTOUT  DD DSN=YOUR OUTPUT FILE IN REVERSE ORDER,
//         DISP=(NEW,CATLG,DELETE),UNIT=SYSDA,
//         SPACE=(CYL,(X,Y),RLSE)
//SYSIN    DD  *
 INREC FIELDS=(1,80,SEQNUM,8,ZD)
 SORT FIELDS=(81,8,ZD,D)
 OUTREC FIELDS=(1,80)
/*                        

Example:

//STEP0100 EXEC PGM=SORT                       
//SYSOUT   DD SYSOUT=*                         
//SORTIN   DD DSN=T365T.T365F1.INPUT,DISP=SHR  
//SORTOUT  DD DSN=T365T.T365F1.OUTPUT,         
//            DISP=(NEW,CATLG,DELETE),LRECL=57,
//            SPACE=(CYL,(1,2),RLSE),AVGREC=K  
//SYSIN    DD  *                               
 INREC FIELDS=(1,57,SEQNUM,8,ZD)               
 SORT FIELDS=(58,8,ZD,D)                       
 OUTREC FIELDS=(1,57)                          
/*                                             

//*                                            

Input file:







Output file: