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

Need to compare 2 fields in 2 files before joining them


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

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Wed May 02, 2007 11:52 pm
Reply with quote

Need to compare 2 fields in 2 files before joining them

Key positions :
Key1 : file1 : 7th col, 3 char to be compared with file2 : 7th col, 3 char
Key2 : file1 : 14th col, 5 char to be compared with file2 : 1st col, 5 char
File1 format
Code:

     |014|CI|PL001|                    |002|

File2 format
Code:

PL001;014;NORTH COAST HOUSE

Output format
Code:

     |014|CI|PL001|NORTH COAST HOUSE   |002|
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: Thu May 03, 2007 1:08 am
Reply with quote

What is the RECFM and LRECL of each input file?

If the keys in file1 and file2 don't match, do you want to omit those records from the output file?

Can there be duplicate keys within input file1?

Can there be duplicate keys within input file2?

Please show an example with more than one record in each input file that covers all of the possible variations, and the expected output records.
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Thu May 03, 2007 11:27 am
Reply with quote

Hi Frank

Lrecl for file1 is 53
Lrecl for file2 is 155

With the key combination of two fields, there can be duplicates in file1, but none in file2
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Thu May 03, 2007 11:49 am
Reply with quote

Frank..
Forgot to mention - there will definitely be records in file2 with the combination key for all recods in file1

File1

Code:

     |620|KS|DC001|                    |002|HULLO| 
AC210|021|IN|DC002|                    |002|HOLLA| 
AD210|021|IN|DC004|                    |002|HOLLA| 


File2:

Code:

DC001;620;COL.WHSE.BKY.STORG. ;1299 ALUM CREEK DR.     
DC002;021;COLS.COOKIE WHSE STR;2880 WILLIAMS DR.       
DC004;021;COLS. BAKERY STORES ;1100 PORT DR.           


Output
Code:

AC210|620|KS|DC001|COLS.WHSE.BKY.STORG. |002|HULLO|
AC210|021|IN|DC002|COLS.COOKIE WHSE STR |002|HULLO|
AD210|021|IN|DC004|COLS.CAKE STORAGE    |002|HOLLA|
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Thu May 03, 2007 11:53 am
Reply with quote

Sorry Frank..

the output file is supposed to be

Code:

     |620|KS|DC001|COLS.WHSE.BKY.STORG. |002|HULLO|
AC210|021|IN|DC002|COLS.COOKIE WHSE STR |002|HULLO|
AD210|021|IN|DC004|COLS.CAKE STORAGE    |002|HOLLA|
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: Thu May 03, 2007 10:54 pm
Reply with quote

I believe your DC004 record should have COLS. BAKERY STORES.

At any rate, here's a DFSORT/ICETOOL job that will do what you asked for. The output records will be in key1/key2 order. If you want them in a different order, you can do another SORT.

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN2 DD DSN=...  input file2 (FB/155)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//CON DD DSN=*.T1,VOL=REF=*.T1,DISP=(OLD,PASS)
//    DD DSN=...  input file1 (FB/53)
//OUT DD DSN=...  output file (FB/53)
//TOOLIN   DD    *
COPY FROM(IN2) TO(T1) USING(CTL1)
SPLICE FROM(CON) TO(OUT) ON(7,3,CH) ON(14,5,CH) -
 WITHALL WITH(1,19) WITH(40,14)
/*
//CTL1CNTL DD *
  INREC BUILD=(7:7,3,14:1,5,20:11,20,53:X)
/*
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Mon May 07, 2007 9:34 pm
Reply with quote

Thanks frank,
Your suggestion is working fine.
Back to top
View user's profile Send private message
kaleelahamed

New User


Joined: 08 Jun 2006
Posts: 45
Location: Trumbull, CT

PostPosted: Wed May 09, 2007 11:04 am
Reply with quote

I used the above forum for my work...
And its working perfect....Thanks once again for the Author and Moderator...Thanks icon_biggrin.gif
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 0
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