Add header and trailer and update trailer with detail record

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

Moderators: Frank Yaeger, Moderator Group

Post Reply
papzz
Member
Posts: 5
Joined: Fri Jun 03, 2011 10:49 pm

Add header and trailer and update trailer with detail record

Post by papzz » Fri Sep 30, 2011 9:45 am

Hi,

I have 2 files, the first containing the header and trailer and the second file containing the detail records only.
My requirement is to add the header and trailer along with the detail file and also update the trailer count.
Can we achieve this in one step? Please help :(

Header :: 00000000000000020110825
Trailer :: 999999999999999000000000 where the last 9 digits are the rec count

The file with detail records is a VB file, LRECL=215
O/P file is expected to be having same attributes as the I/P file

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Sat Oct 01, 2011 12:25 am

Probably, but I need more details to tell you how.
The file with detail records is a VB file, LRECL=215
What is the RECFM and LRECL of the file with the header and trailer records?

Can we identify the header record by the '0' in position 1 and the trailer record by the '9' in position 1 (assuming that the data records do not have a '0' or '9' in position 1?). If not, how can we identify the header and trailer record?

In the output file, do you want the header records, detail records from file1, detail records from file2 and updated trailer record, in that order? Or do you want something else (e.g. sorted detail records)?
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

papzz
Member
Posts: 5
Joined: Fri Jun 03, 2011 10:49 pm

Post by papzz » Sun Oct 02, 2011 5:50 pm

Hi Frank,

The RECFM and LRECL of the file with header and trailer will be same as the detail file i.e VB file, LRECL=215
I want the header from file1
detail from file 2 (It is already in sorted order, so no need to sort again)
And trailer from file1 and updated

The header record is identified by the '0' in position 1 and the trailer record by the '9' in position 1

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Tue Oct 04, 2011 1:08 am

Assuming you want the count of the detail records, not the count of the detail records + header + trailer, you can use a DFSORT job like the following:

Code: Select all

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file1 (VB/215)
//       DD DSN=.... input file2 (VB/215)
//SORTOUT DD DSN=...  output file (VB/215)
//SYSIN DD *
  INREC IFTHEN=(WHEN=(5,1,SS,EQ,C'09'),BUILD=(1,4,5,1,5)),     
        IFTHEN=(WHEN=NONE,BUILD=(1,4,C'1',5))                  
  SORT FIELDS=(5,1,CH,A)                                       
  OUTREC BUILD=(1,4,6)                                         
  OUTFIL IFTRAIL=(HD=YES,TRLID=(5,1,CH,EQ,C'9'),               
    TRLUPD=(20:COUNT=(M11,LENGTH=9)))                          
/*
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

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