MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Count Records on Trailer

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
ciberc
Beginner


Joined: 16 Sep 2003
Posts: 3
Topics: 2

PostPosted: Fri Jul 16, 2004 7:06 am    Post subject: Count Records on Trailer Reply with quote

I would like to sort an input file and split it into 3 output files (header, detail with duplicate record removed, trailer with count from detail output file):
Code:
                                         
//STEP0020 EXEC PGM=SYNCSORT
//SORTMSG DD SYSOUT=*
//SORTIN DD DSN=SORT.INPUT,
// DISP=SHR
//SORTOF1 DD DSN=SORTED.HEADER,
// DISP=(NEW,CATLG,CATLG),
// DCB=(RECFM=FB,LRECL=80),
// SPACE=(TRK,(10,10),RLSE)
//SORTOF2 DD DSN=SORTED.DETAIL,
// DISP=(NEW,CATLG,CATLG),
// DCB=(RECFM=FB,LRECL=80),
// SPACE=(TRK,(100,10),RLSE)
//SORTOF3 DD DSN=SORTED.TRAILER,
// DISP=(NEW,CATLG,CATLG),
// DCB=(RECFM=FB,LRECL=80),
// SPACE=(TRK,(10,10),RLSE)
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSDUMP DD SYSOUT=*
//SYSIN DD *
  SORT FIELDS=(5,6,CH,A)
  SUM FIELDS=NONE
  OUTFIL FNAMES=SORTOF1,
  INCLUDE=(1,4,CH,EQ,C'1HDR')
  OUTFIL FNAMES=SORTOF2,
  INCLUDE=(1,4,CH,EQ,C'2DTL')
  OUTFIL FNAMES=SORTOF3,
  TRAILER1=(1:'9TRL',5:DATENS=(4MD),13:COUNT),
  REMOVECC
/*

Code:

SORTIN:
1HDR20040713SOURCE
2DTLKEY001
2DTLKEY002
2DTLKEY001
9TRL2004071300000000003

SORTOF1: (EXPECTED)
1HDR20040713SOURCE

SORTOF2: (EXPECTED)
2DTLKEY001
2DTLKEY002

SORTOF3: (EXPECTED)
9TRL2004071300000000002


When running the sort , I got the incorrect trailer output:
Code:

SORTOF3:
2DTLKEY001
2DTLKEY002
9TRL2004071300000000002


Could any one anyone tell me what went wrong?


Thanks,

Wallace
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Fri Jul 16, 2004 7:47 am    Post subject: Reply with quote

Wallace,

If you don't need the detail records in the TRAILER file, all you need is to add NODETAIL parm to SOTOF3 outfil. You also don't require the SORTMSG, SYSPRINT, SYSDUMP dd names.

But to get the updated count excluding the header record is a little bit tricky. The following JCL will give you the desired results.I assumed that your input file LRECL is 80 and is of FB recfm.

We add a seqnum on OUTREC FIELDS which starts from zero. By doing so, the header record is not counted as part of the records. And we use this on the trailer for getting the total detail records after you are done with eliminating the dups.

Code:

//STEP0100 EXEC PGM=SYNCSORT                               
//SYSOUT  DD SYSOUT=*                                     
//SORTIN DD *                                             
1HDR20040713SOURCE                                         
2DTLKEY001                                                 
2DTLKEY002                                                 
2DTLKEY001                                                 
9TRL2004071300000000003                                   
//SORTOF1 DD DSN=YOUR HEADER FILE,
//           DISP=(NEW,CATLG,DELETE),
//           UNIT=SYSDA,
//           SPACE=(TRK,(1,1),RLSE)
//SORTOF2 DD DSN=YOUR DETAIL RECORD FILE,
//           DISP=(NEW,CATLG,DELETE),
//           UNIT=SYSDA,
//           SPACE=(CYL,(25,25),RLSE)
//SORTOF3 DD DSN=YOUR TRAILER FILE,
//           DISP=(NEW,CATLG,DELETE),
//           UNIT=SYSDA,
//           SPACE=(TRK,(1,1),RLSE)
//SYSIN DD * 
  OMIT COND=(1,4,CH,EQ,C'9TRL')                                             
  SORT FIELDS=(5,6,CH,A)                                   
  SUM FIELDS=NONE                                         
  OUTREC FIELDS=(1,80,SEQNUM,8,ZD,START=0)                 
  OUTFIL FNAMES=SORTOF1,INCLUDE=(1,4,CH,EQ,C'1HDR'),       
  OUTREC=(1,80)                                           
  OUTFIL FNAMES=SORTOF2,INCLUDE=(1,4,CH,EQ,C'2DTL'),       
  OUTREC=(1,80)                                           
  OUTFIL FNAMES=SORTOF3,NODETAIL,REMOVECC,OUTREC=(1,80),   
  TRAILER1=(1:'9TRL',5:DATENS=(4MD),13:81,8)               
/*


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ciberc
Beginner


Joined: 16 Sep 2003
Posts: 3
Topics: 2

PostPosted: Fri Jul 16, 2004 9:21 am    Post subject: Reply with quote

Thanks Kolusu, I tried your recommendation and it worked perfectly! You are GOOD!!
Back to top
View user's profile Send private message
Dinesh Kumar
Beginner


Joined: 12 Oct 2004
Posts: 13
Topics: 6

PostPosted: Tue Oct 12, 2004 1:32 am    Post subject: Reply with quote

Hi ALL,
The following Sort Card can be used to have a single output file (header, detail with duplicate record removed, trailer with count from detail output file)

Code:

Code:
//STEP0100 EXEC PGM=SYNCSORT                               
//SYSOUT  DD SYSOUT=*                                     
//SORTIN DD *                                             
1HDR20040713SOURCE                                         
2DTLKEY001                                                 
2DTLKEY002                                                 
2DTLKEY001                                                 
9TRL2004071300000000003                                   
//SORTOUT DD DSN=YOUR OUTPUT FILE,
//           DISP=(NEW,CATLG,DELETE),
//           UNIT=SYSDA,
//           SPACE=(TRK,(1,1),RLSE)
//SYSIN DD *     
OMIT COND=(1,4,CH,EQ,C'9TRL')                   
SORT FIELDS=(5,6,CH,A)             
SUM FIELDS=NONE                             
OUTREC FIELDS=(1,80,SEQNUM,8,ZD,START=0),
OUTFIL FNAMES=SORTOUT,REMOVECC,OUTREC=(1,80),
TRAILER1=(1:'9TRL',DATENS=(4MD),13:81,8)

_________________
Thanks & Rgds
Dinesh
Back to top
View user's profile Send private message Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group