Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to insert header recs for a group of some detail recs?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Karthigaiselvan

New User


Joined: 11 Dec 2006
Posts: 35
Location: India

PostPosted: Thu Sep 13, 2007 11:02 pm    Post subject: How to insert header recs for a group of some detail recs?
Reply with quote

Hi,

I want to create multiple header records with a count of detail records to group based on a key field.

For ex -
I have an input file of the following record lay out

Code:

ENO                    DNO
------                 -----
0001                   1000
0002                   1000
0003                   1000
0004                   1001
0005                   1001
0006                   1002


Now i want to get the counts of all employees working for each department. i.e. my output file should look like

Code:

ENO                    DNO
------                 -----
HEADER                 1000   03
0001                   1000
0002                   1000
0003                   1000
HEADER                 1001   02
0004                   1001
0005                   1001
HEADER                 1002   01
0006                   1002


Any SORT tricks for this?
Back to top
View user's profile Send private message

CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Thu Sep 13, 2007 11:44 pm    Post subject:
Reply with quote

As has been shown in other posts, the headers need to be generated as trailers and then sorted to the front of each key group....
Take a look at Header with record statistics
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri Sep 14, 2007 12:03 am    Post subject:
Reply with quote

Karthi,

Here's a DFSORT/ICETOOL job that will do what you asked for:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD DSN=...  input file
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//CON DD DSN=*.T1,VOL=REF=*.T1,DISP=(OLD,PASS)
//    DD DSN=*.IN,VOL=REF=*.IN,DISP=(OLD,PASS)
//OUT DD DSN=...  output file
//TOOLIN   DD    *
COPY FROM(IN) USING(CTL1)
SORT FROM(CON) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
  OUTFIL FNAMES=T1,REMOVECC,NODETAIL,
    SECTIONS=(24,4,
      TRAILER3=('HEADER',24:24,4,31:COUNT=(EDIT=(TT))))
/*
//CTL2CNTL DD *
  OPTION EQUALS
  SORT FIELDS=(24,4,CH,A)
/*
Back to top
View user's profile Send private message
Karthigaiselvan

New User


Joined: 11 Dec 2006
Posts: 35
Location: India

PostPosted: Fri Sep 14, 2007 10:29 pm    Post subject: Reply to: How to insert header recs for a group of some deta
Reply with quote

Thanks Frank,

I am trying to understand the sort job you have given.

Can you please explain what the following will do?

Code:

  SECTIONS=(24,4,
      TRAILER3=('HEADER',24:24,4,31:COUNT=(EDIT=(TT))))
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri Sep 14, 2007 11:30 pm    Post subject:
Reply with quote

SECTIONS=(24,4 - starts a new "section" whenever the value in 24-27 changes (e.g. when it changes from 1000 to 1001). Every record with the same value in 24-27 is part of the same section. So the three 1000 records are in the first section, the two 1001 records are in the second section and the 1002 record is in the third section.

TRAILER3 - adds a trailer record for each section.

'HEADER' - puts the constant 'HEADER' in output positions 1-6 of the trailer record for each section.

24:24,4 - puts input positions 24-27 in output positions 24-27 of the trailer record fo each section. For the first section, that's 1000, for the second section 1001 and for the third section 1002.

31:COUNT=(EDIT=(TT)) - puts the count of records in each section in output positions 31-32 of the trailer record for each section. For the first section, that's 03 (there are three 1000 records), for the second section 02 and for the third section 01.

If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

www.ibm.com/servers/storage/support/software/sort/mvs/srtmpub.html
Back to top
View user's profile Send private message
Karthigaiselvan

New User


Joined: 11 Dec 2006
Posts: 35
Location: India

PostPosted: Mon Sep 17, 2007 10:10 am    Post subject: Reply to: How to insert header recs for a group of some deta
Reply with quote

Hi Frank,

Thank you verymuch for your help!
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Syncsort Help to group fields sudhakarraju SYNCSORT 6 Thu Dec 29, 2016 1:38 am
No new posts For each given key value, how to keep... Div Grad DFSORT/ICETOOL 7 Fri Nov 11, 2016 11:38 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm
No new posts Get Record count in summary record fo... Atul Banke DFSORT/ICETOOL 21 Fri Sep 23, 2016 4:17 pm
No new posts Insert Lines in JCL with Rexx after a... Willy Jensen CLIST & REXX 3 Tue Aug 30, 2016 4:18 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us