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 Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts find RACF group for access to spooled... jzhardy JCL & VSAM 1 Mon May 08, 2017 11:46 am
No new posts Group Data based on a key Arun Raj DFSORT/ICETOOL 7 Thu Apr 27, 2017 11:29 pm
No new posts Need Help with : IFTHEN(WHEN=GROUP) Sumanta_89 DFSORT/ICETOOL 1 Wed Apr 19, 2017 5:23 pm
No new posts Group elements using ICETOOL Learncoholic DFSORT/ICETOOL 2 Fri Apr 14, 2017 11:01 am


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