DFSORT - update count in multiple trailers of same dataset

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
nachiyappan
Member
Posts: 3
Joined: Wed Nov 20, 2013 3:28 am

DFSORT - update count in multiple trailers of same dataset

Post by nachiyappan » Wed Nov 20, 2013 3:40 am

The trailer count in batch trailer needs to be updated with the count of detail records and finally the file trailer needs to be updated with all of the detail records excluding the batch header and trailer counts.

For example, input file is

Code: Select all

01 Filer header
02 batch header 1 
10 detail record
10 detail record
10 detail record
20 000002 batch trailer 1 record 
02 batch header 2 
10 detail record
10 detail record
10 detail record
20 000002 batch trailer 2 record
99 000004 file trailer 
Output required is

Code: Select all

01 Filer header
02 batch header 1 
10 detail record
10 detail record
10 detail record
20 000003 batch trailer 1 record 
02 batch header 2 
10 detail record
10 detail record
10 detail record
20 000003 batch trailer 2 record
99 000006 file trailer 

How can this be done using DFSORT? I went through this forum to check for a solution myself, but ended up seeing only for single trailer updates only. The example mentioned in the following link also shows to split different keys to separate output datasets.
http://pic.dhe.ibm.com/infocenter/zos/v ... cg6044.htm

Can you please help?

Thanks,
Nachi

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Wed Nov 20, 2013 12:50 pm

You'll need two separate SEQNUM (at least). Look at the RESTART of SEQNUM in your documentation.

Why I say "at least" relates to how happy you are that the structure of the file is good. If happy, it would be OK to use some calculation. If not happy (and the trailers are already wrong, aren't they) then perhaps take the chance to also verify the structure of the file.

You might want to consider using IFTHEN=(WHEN=GROUP as well.

nachiyappan
Member
Posts: 3
Joined: Wed Nov 20, 2013 3:28 am

Post by nachiyappan » Wed Nov 20, 2013 7:24 pm

Thanks.
I forgot to mention that there could be any number of batches in the dataset and all of the batch trailer count needs to be updated according to the number of detail records present in them.

Using WHEN=GROUP, and PUSH parameter, I am able to introduce the identity for each group, however I am not able to figure out on how to update the trailer of each group.

Any suggestions?

Thanks,
Nachi

skolusu
Member
Posts: 43
Joined: Sat Jul 26, 2008 12:38 am

Post by skolusu » Wed Nov 20, 2013 11:49 pm

nachiyappan,

Use the following DFSORT JCL which will give you the desired results. I assumed that your input has LRECL=80 and RECFM=FB

Code: Select all

//STEP0100 EXEC PGM=SORT                                            
//SYSOUT   DD SYSOUT=*                                              
//SORTIN   DD *                                                     
01 FILER HEADER                                                     
02 BATCH HEADER 1                                                   
10 DETAIL RECORD                                                    
10 DETAIL RECORD                                                    
10 DETAIL RECORD                                                    
20 000002 BATCH TRAILER 1 RECORD                                    
02 BATCH HEADER 2                                                   
10 DETAIL RECORD                                                    
10 DETAIL RECORD                                                    
10 DETAIL RECORD                                                    
20 000002 BATCH TRAILER 2 RECORD                                    
99 000004 FILE TRAILER                                              
//SORTOUT  DD SYSOUT=*                                              
//SYSIN    DD *                                                     
  OPTION COPY                                                       
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,2,CH,EQ,C'02'),PUSH=(81:SEQ=6)),
  IFTHEN=(WHEN=(1,2,CH,EQ,C'20'),                                   
  OVERLAY=(4:81,6,ZD,SUB,+2,M11,LENGTH=6,88:4,6))                   
                                                                    
  OUTFIL BUILD=(1,80),IFTRAIL=(HD=YES,TRLID=(1,2,CH,EQ,C'99'),      
  TRLUPD=(4:TOT=(88,6,ZD,M11,LENGTH=6)))                            
//*
The output from this job is

Code: Select all

01 FILER HEADER                       
02 BATCH HEADER 1                     
10 DETAIL RECORD                      
10 DETAIL RECORD                      
10 DETAIL RECORD                      
20 000003 BATCH TRAILER 1 RECORD      
02 BATCH HEADER 2                     
10 DETAIL RECORD                      
10 DETAIL RECORD                      
10 DETAIL RECORD                      
20 000003 BATCH TRAILER 2 RECORD      
99 000006 FILE TRAILER                
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

nachiyappan
Member
Posts: 3
Joined: Wed Nov 20, 2013 3:28 am

Post by nachiyappan » Thu Nov 21, 2013 1:12 am

skolusu,

Great. I got the desired output. Thanks for providing me with the solution. Very helpful.

Thanks,
Nachi

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others