Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 MXG - Processing Compressed DB2 SMF r... vasanthz All Other Mainframe Topics 2 Thu May 10, 2018 12:47 am
No new posts Extract the records with a PD field's... sudhakar84 DFSORT/ICETOOL 11 Mon Apr 02, 2018 7:26 pm
No new posts Merge 2 records sancraig16 SYNCSORT 19 Tue Mar 27, 2018 8:17 pm
No new posts Group changes and numbering the groups Auryn DB2 2 Tue Mar 20, 2018 7:12 pm
No new posts Copy set of records based on condition krish.deepu SYNCSORT 2 Thu Mar 08, 2018 11:39 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us