IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Count records excluding header/trailer


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
gaurav.rajvanshi

New User


Joined: 08 Jul 2010
Posts: 23
Location: Mainframe World

PostPosted: Thu Sep 15, 2011 6:15 pm
Reply with quote

My file has multiple headers/trailers. I require the count of the records excluding the headers/trailers but for specific headers/trailers.

Sample File is like:
HDR 0001
Rec1
Rec2
Rec3
TRL 0001
HDR 0002
Rec1
Rec2
TRL 0002
HDR 0003
Rec1
Rec2
Rec3
TRL 0003

I want output like
HDR 0001 : Count = 3
HDR 0002 : Count = 2
HDR 0003 : Count = 3
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Sep 15, 2011 7:16 pm
Reply with quote

And how are you doing so far? What have you tried? Where is it not working?

Have you looked through the forum for any examples which you might be able to modify? Have you googled for same?
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Sep 15, 2011 10:12 pm
Reply with quote

gaurav.rajvanshi,

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

Code:

//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD *                                                     
HDR 0001                                                             
REC1                                                                 
REC2                                                                 
REC3                                                                 
TRL 0001                                                             
HDR 0002                                                             
REC1                                                                 
REC2                                                                 
TRL 0002                                                             
HDR 0003                                                             
REC1                                                                 
REC2                                                                 
REC3                                                                 
TRL 0003                                                             
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                     
  SORT FIELDS=COPY                                                   
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'HDR'),PUSH=(81:5,4))   
  OUTFIL REMOVECC,NODETAIL,BUILD=(80X),                             
  SECTIONS=(81,4,TRAILER3=('HDR ',81,4,' : ',COUNT-2=(M10,LENGTH=6)))
//*



output is
Code:

HDR 0001 :      3
HDR 0002 :      2
HDR 0003 :      3
Back to top
View user's profile Send private message
gaurav.rajvanshi

New User


Joined: 08 Jul 2010
Posts: 23
Location: Mainframe World

PostPosted: Fri Sep 16, 2011 12:59 am
Reply with quote

Thanks a lot Skolusu icon_biggrin.gif
Back to top
View user's profile Send private message
View previous topic : : View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Format data from multiple records usi... SYNCSORT 4
No new posts count contained values of several col... DB2 5
No new posts DB2 Query to get the count of Unique ... DB2 2
No new posts Sort SMF records? SYNCSORT 6
No new posts To Sort detail records in a file with... SYNCSORT 5
Search our Forums:


Back to Top