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

Sum Group of Records


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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 Developer


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

PostPosted: Thu Feb 07, 2008 10:07 pm
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
Reply with quote

Thanks a lot Frank..
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Wed Sep 03, 2008 4:31 am
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:

Use [URL] BBCode for External Links
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Join multiple records using splice DFSORT/ICETOOL 5
Search our Forums:

Back to Top