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

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


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


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

PostPosted: Tue Feb 03, 2009 11:02 pm
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:

Use [URL] BBCode for External Links
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
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 Developer


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

PostPosted: Wed Feb 04, 2009 9:15 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Merge two VSAM KSDS files into third ... JCL & VSAM 6
Search our Forums:

Back to Top