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
 

 

Merge two files into third and sum up a field with same key

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

New User


Joined: 30 May 2006
Posts: 10
Location: Pune

PostPosted: Tue Feb 03, 2009 7:36 pm    Post subject: Merge two files into third and sum up a field with same key
Reply with quote

I have two files both of the same layout
eg :

File 1 :-
Key Field to sumup
H1111 000 000 123
H2222 000 000 777

File 1 :-
H1111 000 000 456
H2222 000 000 789
H3333 000 000 548

hear the key is H1111 and while copying into the third file ,if the key is same in both the records, i want to retain only the record in file 1 but sum up the fields 123 & 456 in that column

I want to use Sort utility for this
can any one suggest me a sort card for the same
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: Tue Feb 03, 2009 11:02 pm    Post subject:
Reply with quote

You can use a simple SORT/SUM for this like the DFSORT job below. However, note that for your H2222 records, 777+789 will overflow 3 digits so both records will be kept. You need to indicate what you want to do about overflow.

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
H1111 000 000 123
H2222 000 000 777
/*
//  DD *
H1111 000 000 456
H2222 000 000 789
H3333 000 000 548
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  OPTION EQUALS
  SORT FIELDS=(1,5,CH,A)
  SUM FIELDS=(15,3,ZD)
/*


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
nitesh.mulay

New User


Joined: 30 May 2006
Posts: 10
Location: Pune

PostPosted: Wed Feb 04, 2009 11:39 am    Post subject: Reply to: Merge two files into third and sum up a field with
Reply with quote

Thanks for the reply Frank
i had few more questions
1) can this be done using Sort Utility insted of ICEMAN
2) Will this create any problem if the fields to be summed off has a declaration of s9(5)v99, in this case in the sort card should the length be given as (starting position , 7)
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 Feb 04, 2009 9:15 pm    Post subject:
Reply with quote

Quote:
can this be done using Sort Utility insted of ICEMAN


PGM=ICEMAN and PGM=SORT both use DFSORT. So your question doesn't make any sense. Use PGM=SORT instead of PGM=ICEMAN if you like - there's no difference between them.

Quote:
Will this create any problem if the fields to be summed off has a declaration of s9(5)v99, in this case in the sort card should the length be given as (starting position , 7)


Yes, for S9(5)v99, you would use a length of 7.
Back to top
View user's profile Send private message
nitesh.mulay

New User


Joined: 30 May 2006
Posts: 10
Location: Pune

PostPosted: Thu Feb 05, 2009 9:44 am    Post subject: Reply to: Merge two files into third and sum up a field with
Reply with quote

Thanks a lot frank for this info i tried out with SORT and it is working fine
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 Append data from two files into a sin... Praveen04 DFSORT/ICETOOL 5 Thu Mar 16, 2017 7:29 pm
No new posts SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts IMS DB-How to update a record (a sing... Nic Clouston IMS DB/DC 9 Thu Mar 09, 2017 4:38 pm
No new posts outrec field outside range Danielle.Filteau SYNCSORT 10 Sat Mar 04, 2017 2:37 am
No new posts To Merge mutliple records into a sing... anandgbe DFSORT/ICETOOL 6 Wed Feb 22, 2017 8:49 am


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