Update the trailer counts using JCL

256 views Asked by At

I have a input file having different types of Record. Different types of records are identified by column 1. For example for header records column1 is having value 0, for trailer records column1 is having value 9. For other records column1 is having value from 1 to 5. Trailer of the file is having count of each types of records. Trailer is like below : column1 is having value 9 so that it will be identified as trailer record Coulmn2-10 is having count of record type1 Column11-19 is having count of record type2 Cilumn20-28 is having count of record type3 Coulmn29-37 is having count of record type4 column38-46 is having count of record type5 So, after doing some sort include data has been updated in output file. So how to update the count of the trailer record using JCL.

2

There are 2 answers

0
Kolusu On BEST ANSWER

Thanks Kolusu for your answer. My input file is VB file having 4700 record length

Azhar,

It would have been nice if you had mentioned that upfront so that we don't have to work on multiple solutions. Also you could have tried to change the above posted solution to your requirement, however you simply came back with the requirement hoping for a hand down solution. Please try to understand the solution and then if you run into an issue, you can comeback which shows that you have put some effort.

Either way here is an UNTESTED solution which would meet your requirements. In this case I assumed that we can generate a new Trailer record with the updated counts as you only have the counts on it.

//SYSIN    DD *                                         
  OPTION COPY,VLSCMP                                    
  OMIT COND=(05,1,CH,EQ,C'9',OR,                        
             15,4,CH,EQ,C'DROP')                        
                                                        
  INREC IFTHEN=(WHEN=INIT,                              
         BUILD=(1,4,C'00000',5)),                       
        IFTHEN=(WHEN=INIT,                              
       OVERLAY=(05:10,01,CHANGE=(5,C'1',C'10000',       
                                   C'2',C'01000',       
                                   C'3',C'00100',       
                                   C'4',C'00010',       
                                   C'5',C'00001'),      
                         NOMATCH=(5,5)))                
                                                        
  OUTFIL BUILD=(1,4,10),                                
  REMOVECC,                                             
  TRAILER1=('9',                                        
            TOT=(5,1,ZD,M11,LENGTH=9),                  
            TOT=(6,1,ZD,M11,LENGTH=9),                  
            TOT=(7,1,ZD,M11,LENGTH=9),                  
            TOT=(8,1,ZD,M11,LENGTH=9),                  
            TOT=(9,1,ZD,M11,LENGTH=9))                  
/*                                                      
1
Kolusu On

Azhar,

Assuming that your input has RECFM=FB and LRECL=80, the following DFSORT JCL will give you the desired results.

//STEP0100 EXEC PGM=SORT                                
//SYSOUT   DD SYSOUT=*                                  
//SORTIN   DD *                                         
0 HEADER                                                
1 AAA 101 PICK                                          
1 AAA 101 PICK                                          
1 AAA 101 DROP                                          
1 AAA 101 PICK                                          
2 ABC 101 PICK                                          
2 ABC 201 PICK                                          
2 ABC 301 DROP                                          
3 DEF 101 PICK                                          
3 DEF 201 350                                           
4 XQW 201 PICK                                          
5 REW 201 PICK                                          
5 REW 201 PICK                                          
5 REW 201 DROP                                          
5 REW 201 PICK                                          
5 REW 201 PICK                                          
9000000004000000003000000002000000001000000006          
//SORTOUT  DD SYSOUT=*                                  
//SYSIN    DD *                                         
  OMIT COND=(11,4,CH,EQ,C'DROP')                        
  OPTION COPY                                           
  INREC OVERLAY=(81:C'00000',                           
                 81:01,01,CHANGE=(5,C'1',C'10000',      
                                    C'2',C'01000',      
                                    C'3',C'00100',      
                                    C'4',C'00010',      
                                    C'5',C'00001'),     
                         NOMATCH=(81,5))                
                                                        
  OUTFIL BUILD=(1,80),                                  
         IFTRAIL=(TRLID=(1,1,CH,EQ,C'9'),               
          TRLUPD=(02:TOT=(81,1,ZD,M11,LENGTH=9),        
                  11:TOT=(82,1,ZD,M11,LENGTH=9),        
                  20:TOT=(83,1,ZD,M11,LENGTH=9),        
                  29:TOT=(84,1,ZD,M11,LENGTH=9),        
                  38:TOT=(85,1,ZD,M11,LENGTH=9)))       
/*                                                  

The output of this is

0 HEADER                                               
1 AAA 101 PICK                                         
1 AAA 101 PICK                                         
1 AAA 101 PICK                                         
2 ABC 101 PICK                                         
2 ABC 201 PICK                                         
3 DEF 101 PICK                                         
3 DEF 201 350                                          
4 XQW 201 PICK                                         
5 REW 201 PICK                                         
5 REW 201 PICK                                         
5 REW 201 PICK                                         
5 REW 201 PICK                                         
9000000003000000002000000002000000001000000004