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

Merging two files and remving duplicates


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
satish kanamarlapudi

New User


Joined: 23 Jul 2008
Posts: 29
Location: Little Rock - Arkansas

PostPosted: Wed Dec 17, 2008 10:52 am
Reply with quote

Hi,

My requirement is that :-

I have 2 files and i need to merge them as a single file and remove duplicates on them and wants to get 2 diff fields from 2 input files.

Need to remove duplicates on 1st 10 bytes on Fin date and wants GRP-SUM from 1st file and CLAIM-SUM from 2nd file for the corresponding Fin date :-

1st file :-

1-10 bytes(Fin Date) 11-15 bytes (GRP-SUM)

2008-10-01 +460.00
2008-11-01 +410.00
2008-12-01 +420.00
2008-09-01 +430.00
2008-08-01 +440.00


2nd file :-

1-10 bytes(Fin Date) 11-15 bytes (CLAIM-SUM)

2008-10-01 +360.00
2008-11-01 +310.00
2008-12-01 +320.00
2008-09-01 +330.00
2008-08-01 +340.00
2008-07-01 +340.00


O/p file :-

1-10 bytes(Fin Date) 11-15 bytes (CLAIM-SUM) 15-20 bytes (GRP-SU)
from 2nd file from 1st file

2008-10-01 +360.00 +460.00
2008-11-01 +310.00 +410.00
2008-12-01 +320.00 +420.00
2008-09-01 +330.00 +430.00
2008-08-01 +340.00 +430.00
2008-07-01 +340.00 0.00

Please help me out in this.

Thx,
satish
Back to top
View user's profile Send private message
nelson.pandian

Active User


Joined: 09 Apr 2008
Posts: 133
Location: Phoenix, AZ

PostPosted: Wed Dec 17, 2008 5:51 pm
Reply with quote

Try this code.

Code:
//S1   EXEC  PGM=ICETOOL                                       
//TOOLMSG   DD  SYSOUT=*                                       
//DFSMSG    DD  SYSOUT=*                                       
//IN1 DD *                                                     
2008-10-01 +360.00                                             
2008-11-01 +310.00                                             
2008-12-01 +320.00                                             
2008-09-01 +330.00                                             
2008-08-01 +340.00                                             
2008-07-01 +340.00                                             
/*                                                             
//IN2 DD *                                                     
2008-10-01 +460.00                                             
2008-11-01 +410.00                                             
2008-12-01 +420.00                                             
2008-09-01 +430.00                                             
2008-08-01 +440.00                                             
/*                                                             
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS) 
//OUT DD SYSOUT=*                                             
//TOOLIN DD *                                             
COPY FROM(IN1) TO(T1)                                     
COPY FROM(IN2) TO(T1) USING(CTL1)                         
SPLICE FROM(T1) TO(OUT) ON(1,10,CH) KEEPNODUPS -         
    WITHALL WITH(20,7) USING(CTL2)                       
/*                                                       
//CTL1CNTL DD *                                           
  INREC BUILD=(1,10,20:12,7)                             
/*                                                       
//CTL2CNTL DD *                                           
  OUTFIL FNAMES=OUT,IFTHEN=(WHEN=(20,7,CH,EQ,C'       '),
      BUILD=(1,18,1X,20:C'0.00   '))                     
/*


Output:
Code:
2008-07-01 +340.00 0.00   
2008-08-01 +340.00 +440.00
2008-09-01 +330.00 +430.00
2008-10-01 +360.00 +460.00
2008-11-01 +310.00 +410.00
2008-12-01 +320.00 +420.00
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Dec 17, 2008 10:37 pm
Reply with quote

satish kanamarlapudi,

You say your input file is only 15 bytes but the data shown exceeds that. So I am guessing that GRP-SUM and CLAIM-SUM are actually 5 byte packed decimal fields(comp-3)

Since both files are of the same length you can concatenate both files together and get the desired results

Code:

//STEP0100 EXEC PGM=ICEMAN                                           
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD DSN=input file1,DISP=SHR                                       
//         DD DSN=input file2,DISP=SHR                                       
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                       
  OPTION EQUALS                                                       
  SORT FIELDS=(1,10,CH,A)                                             
  OUTREC IFTHEN=(WHEN=INIT,                                           
  OVERLAY=(16:+0,TO=PD,LENGTH=5,SEQNUM,1,ZD,RESTART=(1,10))),         
  IFTHEN=(WHEN=(21,1,ZD,EQ,1),                                       
  OVERLAY=(16:11,5,11:+0,TO=PD,LENGTH=5))                             
                                                                     
  OUTFIL REMOVECC,NODETAIL,                                           
  SECTIONS=(1,10,                                                     
  TRAILER3=(1,10,TOT=(11,5,PD,PD,LENGTH=5),TOT=(16,5,PD,PD,LENGTH=5)))
/*     
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 2
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 Merge two VSAM KSDS files into third ... JCL & VSAM 6
Search our Forums:

Back to Top