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
 

 

Sum Group of Records

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

New User


Joined: 12 Sep 2006
Posts: 12
Location: India

PostPosted: Thu Feb 07, 2008 8:07 pm    Post subject: Sum Group of Records
Reply with quote

Hi,

My requirement is to Sum Up a value against each data record in a group along with the value against its header record and write the header record with the total in a new file. An example will help you understand my statement better.

INPUT FILE:

Code:

LKG12345  10
  USERID1  20
  USERID2  30
  USERID3  40
NUW98765 35
  USERID6  20
  USERID7  15
  USERID8  230
.
.
.
.


DESIRED OUTPUT:

Code:

LKG12345  100
NUW98765 300
.
.
.


The input file is generated as part of an automation hence the header records are not known prior. They vary for every month. (I mean they are not constant, hence cannot be hard coded).

Only difference between the header record and the data record is that the first column of the data records in each group will be a Space.

I would be glad if you could suggest me some way out.

Regards,
Jonty.
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: Thu Feb 07, 2008 10:07 pm    Post subject:
Reply with quote

You can use a DFSORT job like this to do what you asked for:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
LKG12345    10
  USERID1   20
  USERID2   30
  USERID3   40
NUW98765    35
  USERID6   20
  USERID7   15
  USERID8  230
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=(1,1,CH,NE,C' '),
                OVERLAY=(81:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=NONE,
                OVERLAY=(89:SEQNUM,8,ZD,
                         81:81,8,ZD,SUB,89,8,ZD,TO=ZD,LENGTH=8))
  SORT FIELDS=(81,8,ZD,A)
  SUM FIELDS=(11,4,ZD)
  OUTREC IFOUTLEN=80,                                       
    IFTHEN=(WHEN=INIT,OVERLAY=(11:11,4,ZD,EDIT=(IIIT)))     
/*
Back to top
View user's profile Send private message
jontyjun

New User


Joined: 12 Sep 2006
Posts: 12
Location: India

PostPosted: Fri Feb 08, 2008 10:12 am    Post subject:
Reply with quote

Thanks a lot Frank..
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: Wed Sep 03, 2008 4:31 am    Post subject:
Reply with quote

You can do this a bit more easily using the new WHEN=GROUP function of DFSORT available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008) like this:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
LKG12345    10
  USERID1   20
  USERID2   30
  USERID3   40
NUW98765    35
  USERID6   20
  USERID7   15
  USERID8  230
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,NE,C' '),
                PUSH=(81:ID=8))
  SORT FIELDS=(81,8,ZD,A)
  SUM FIELDS=(11,4,ZD)
  OUTREC IFOUTLEN=80,
    IFTHEN=(WHEN=INIT,OVERLAY=(11:11,4,ZD,EDIT=(IIIT)))
/*


For complete details on the new WHEN=GROUP function and the other new functions available with PTF UK90013, see:

www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/
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 Sorting group data rajella DFSORT/ICETOOL 3 Sun Jan 22, 2017 11:32 pm
No new posts Syncsort Help to group fields sudhakarraju SYNCSORT 6 Thu Dec 29, 2016 1:38 am
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm


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