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
 
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 sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts Partial color change of a field in CI... waseem0424 CICS 5 Fri Sep 29, 2017 7:56 pm
No new posts FTP Skip or ignore error and process ... AJAYREDDY All Other Mainframe Topics 3 Wed Sep 27, 2017 8:12 pm
No new posts Comparing 2 Files using Current time arunsoods SYNCSORT 9 Fri Sep 22, 2017 6:00 pm
No new posts Split 1 file into 10 output Files - S... Prasanth Kumar SYNCSORT 5 Sat Sep 16, 2017 12:02 am

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