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

JOIN 2 FILES using Key and write record from 1st file


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
subramanianup
Warnings : 1

New User


Joined: 18 May 2005
Posts: 46
Location: Bangalore, INDIA

PostPosted: Wed Feb 11, 2009 6:17 pm
Reply with quote

Join 2 files with Key is in differnt Places if key matches write records from first file.


Input file 1(Record lenth 80)
1234XXXXXXX...
2345XXXXXXX...


INput File 2(record length 40)
XXXX5464....
XXXX1234....
XXXX2345....
XXXX4546....


The required output file

1234XXXXXXX...
2345XXXXXXX...
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 11, 2009 10:07 pm
Reply with quote

Here's a DFSORT/ICETOOL job that will do what you asked for:

Code:

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN1 DD DSN=...  input file1 (FB/80)
//IN2 DD DSN=...  input file2 (FB/40)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD DSN=...  output file (FB/80)
//TOOLIN DD *
COPY FROM(IN1) TO(T1)
COPY FROM(IN2) TO(T1) USING(CTL1)
SELECT FROM(T1) TO(OUT) ON(1,4,CH) FIRSTDUP
/*
//CTL1CNTL DD *
  INREC BUILD=(1:5,4,80:X)
/*
Back to top
View user's profile Send private message
subramanianup
Warnings : 1

New User


Joined: 18 May 2005
Posts: 46
Location: Bangalore, INDIA

PostPosted: Wed Feb 11, 2009 10:11 pm
Reply with quote

Hi Frank,
One more questions if 1st File is like follows
Input file 1(Record lenth 80)
1234XXXXXXX...
1234XXXXXXX...
1234XXXXXXX...
2345XXXXXXX...


INput File 2(record length 40)
XXXX5464....
XXXX1234....
XXXX2345....
XXXX4546....


The required output file

1234XXXXXXX...
2345XXXXXXX...

Could you please help me how to achieve this?
Back to top
View user's profile Send private message
subramanianup
Warnings : 1

New User


Joined: 18 May 2005
Posts: 46
Location: Bangalore, INDIA

PostPosted: Wed Feb 11, 2009 10:15 pm
Reply with quote

Hi Frank The File 1 looks like as follows
Input file 1(Record lenth 80)
1234XXXXXXX...
2345XXXXXXX...
2345XXXXXXX...
2345XXXXXXX...
2345XXXXXXX...
2345XXXXXXX...

Please omit my above update
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 11, 2009 11:16 pm
Reply with quote

Please start over and show a complete example of the records in each input file and what you expect for output, covering all cases. Indicate if either or both input files has duplicates within it (it appears from your example that input file1 has dups, but input file2 doesn't - is that correct?).
Back to top
View user's profile Send private message
subramanianup
Warnings : 1

New User


Joined: 18 May 2005
Posts: 46
Location: Bangalore, INDIA

PostPosted: Thu Feb 12, 2009 9:49 am
Reply with quote

Sorry Frank I haven't Covered all the Cases. both the Input file containing Duplicates....If matches found from file 1 with File 2 we need to write only one record from first file. My Input file format and expected file format as follows,

Input file 1(Record length 80)
1234XXXXXXX...
2345XXXXXXX...
2345XXXXXXX...
2345XXXXXXX...
2345XXXXXXX...
2345XXXXXXX...

Input file 2(Record length 40)
XXXX5464....
XXXX1234....
XXXX2345....
XXXX2345....
XXXX2345....
XXXX2345....
XXXX4546....
XXXX4546....
XXXX5568....

Output File
1234XXXXXXX...
2345XXXXXXX...
Back to top
View user's profile Send private message
Sushil Kurian

New User


Joined: 09 Feb 2009
Posts: 1
Location: India

PostPosted: Thu Feb 12, 2009 3:00 pm
Reply with quote

Hope this helps.

Code:

//STEP01   EXEC PGM=ICETOOL                                     
//TOOLMSG  DD SYSOUT=*                                         
//DFSMSG   DD SYSOUT=*                                         
//SYSOUT   DD SYSOUT=*                                         
//IN1      DD DSN=input file1 (FB/80)               
//IN2      DD DSN=input file2 (FB/40)               
//TMP1     DD DSN=&&TEMP1,DISP=(MOD,PASS),UNIT=SYSDA,SPACE=(TRK,(5,5))
//OUT      DD DSN=output file (FB/80)                         
//TOOLIN   DD *                                                       
COPY FROM(IN1) TO(TMP1) USING(CTL1)                                 
COPY FROM(IN2) TO(TMP1) USING(CTL2)                                 
SPLICE FROM(TMP1) TO(OUT) ON(1,4,CH) WITH(81,1) USING(CTL3)
/*                                                                   
//CTL1CNTL DD *                                                       
  INREC OVERLAY=(81:C'11')                                           
/*                                                                   
//CTL2CNTL DD *                                                       
  INREC BUILD=(1:5,4,81:C'22')                               
/*                                                                   
//CTL3CNTL DD *                                                       
  OUTFIL FNAMES=OUT,INCLUDE=(81,2,CH,EQ,C'21'),BUILD=(1,80) 
/*         

/*
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 Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Write line by line from two files DFSORT/ICETOOL 7
Search our Forums:

Back to Top