MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Match 2 Files and Create a Common file with matching records

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
ranga_subham
Intermediate


Joined: 31 Jan 2006
Posts: 255
Topics: 72

PostPosted: Thu Apr 08, 2010 2:40 pm    Post subject: Match 2 Files and Create a Common file with matching records Reply with quote

Hi,

I have two input files (LRECL=80, RECFM=FB).

File-1:
Code:

----+----1----+----2----+----3
ABC123   120200
ABC489   100945
ABTM98   120200
A9JCBT   145876
FER001   120200


File-2:
Code:

----+----1----+----2----+----3
100298   PENTA CONS
100945   PORT OF SPAIN
120200   VALERIE CONT.
145876   VIRGO CONT
150432   SHAHS MASTER


My requirement is to match the 6 digits starting at 10th column from File-1 with the 6 digits starting at 1st column in File-2 and if a match found then File-1 should be formatted with content from File-2 as shown below..

Expected output:
Code:

----+----1----+----2----+----3
ABC123   120200    VALERIE CONT.
ABC489   100945    PORT OF SPAIN
ABTM98   120200    VALERIE CONT.
A9JCBT   145876    VIRGO CONT
FER001   120200    VALERIE CONT.


Please let me know the SORT job.

Thanks.
_________________
Ranga
*****
None of us is as smart as all of us - Ken Blanchard
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Apr 08, 2010 3:32 pm    Post subject: Reply with quote

You can use a DFSORT JOINKEYS job like the following to do what you asked for:

Code:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//IN1 DD *
ABC123   120200
ABC489   100945
ABTM98   120200
A9JCBT   145876
FER001   120200
/*
//IN2 DD *
100298   PENTA CONS
100945   PORT OF SPAIN
120200   VALERIE CONT.
145876   VIRGO CONT
150432   SHAHS MASTER
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
  JOINKEYS F1=IN1,FIELDS=(10,6,A)
  JOINKEYS F2=IN2,FIELDS=(1,6,A)
  REFORMAT FIELDS=(F1:1,19,F2:10,19,F1:31,8)
  SORT FIELDS=(39,8,ZD,A)
  OUTREC BUILD=(1,38,80:X)
/*
//JNF1CNTL DD *
  INREC OVERLAY=(31:SEQNUM,8,ZD)
/*

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
papadi
Supermod


Joined: 20 Oct 2009
Posts: 594
Topics: 1

PostPosted: Thu Apr 08, 2010 3:38 pm    Post subject: Reply with quote

Which sort product is used on your system?
_________________
All the best,

di
Back to top
View user's profile Send private message
ranga_subham
Intermediate


Joined: 31 Jan 2006
Posts: 255
Topics: 72

PostPosted: Thu Apr 08, 2010 3:47 pm    Post subject: Thx Reply with quote

Thank you Frank.
_________________
Ranga
*****
None of us is as smart as all of us - Ken Blanchard
Back to top
View user's profile Send private message
Sqlcode
Intermediate


Joined: 15 Dec 2006
Posts: 157
Topics: 38

PostPosted: Wed Apr 14, 2010 10:08 am    Post subject: Reply with quote

Frank,
Out of curiosity what is the purpose of JNF1CNTL in this sort card?
OP never asked for sorted output file and from looking at his expected output, assuming he forgot to mention about sorted o/p, it seems he wants reformatted be sorted on first 6 bytes.

Would below mentioned card work?

Code:
//SORTOUT DD SYSOUT=*
//SYSIN DD *
  JOINKEYS F1=IN1,FIELDS=(10,6,A)
  JOINKEYS F2=IN2,FIELDS=(01,6,A)
  REFORMAT FIELDS=(F1:1,19,F2:10,19)
  SORT FIELDS=(01,06,CH,A)
 /*



Thanks,
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed Apr 14, 2010 12:02 pm    Post subject: Reply with quote

From his input and output example, I assumed that he wanted the output in the original order of the input records. I added the SEQNUM to the file1 records with JNF1CNTL so I could sort on them to get that result. If, in fact, he just needed the output records sorted on the first file1 field, then your job would work. That wasn't the way I read the requirement, but it's certainly a possibility.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Sqlcode
Intermediate


Joined: 15 Dec 2006
Posts: 157
Topics: 38

PostPosted: Wed Apr 14, 2010 12:35 pm    Post subject: Reply with quote

Frank,
Thanks for the quick response and explanation.

Thanks,
Back to top
View user's profile Send private message
ranga_subham
Intermediate


Joined: 31 Jan 2006
Posts: 255
Topics: 72

PostPosted: Tue May 04, 2010 6:15 am    Post subject: Reply with quote

Hi, Frank,

How to apply SEQNUM on IN1 without using JNF1CNTL?

Thanks.
_________________
Ranga
*****
None of us is as smart as all of us - Ken Blanchard
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12382
Topics: 75
Location: San Jose

PostPosted: Tue May 04, 2010 10:41 am    Post subject: Reply with quote

ranga_subham wrote:
Hi, Frank,

How to apply SEQNUM on IN1 without using JNF1CNTL?

Thanks.


You CanNOT do it any other way unless you code multiple steps. What is the problem using JNF1CNTL?
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ranga_subham
Intermediate


Joined: 31 Jan 2006
Posts: 255
Topics: 72

PostPosted: Tue May 04, 2010 11:21 am    Post subject: thx Reply with quote

No issues.......mistaken with CNTL being used with SORT because I saw it used in ICETOOL !!

Thanks.
_________________
Ranga
*****
None of us is as smart as all of us - Ken Blanchard
Back to top
View user's profile Send private message
Anuj Dhawan
Intermediate


Joined: 19 Jul 2007
Posts: 298
Topics: 7
Location: Mumbai,India

PostPosted: Wed May 05, 2010 3:41 am    Post subject: Reply with quote

JNFnCNTLs are used because you are using a JOINKEYS application. Such control cards are optional JCL statements for a JOINKEYS application.

You can also use JOINKEYS with ICETOOL, but you need to care about what control-card you are dealing with - CTLnCNTL or JNFnCNTL. Both are control-cards from a DFSort Application per se but we, as programmers, need to make a choice what will work for us.
_________________
Regards,
Anuj
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed May 05, 2010 11:32 am    Post subject: Reply with quote

Quote:
You can also use JOINKEYS with ICETOOL, but you need to care about what control-card you are dealing with - CTLnCNTL or JNFnCNTL.


It doesn't have to be CTLnCNTL or JNFnCNTL. It's actually:

xxxxCNTL associated with USING(xxxx) in an ICETOOL statement

idFnCNTL associated with TASKID=id on the JOINKEYS statement (the default id is JN).

For complete details on JOINKEYS, including using it with an ICETOOL SORT or COPY operator, see:

http://www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000174
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Anuj Dhawan
Intermediate


Joined: 19 Jul 2007
Posts: 298
Topics: 7
Location: Mumbai,India

PostPosted: Thu May 06, 2010 4:05 am    Post subject: Reply with quote

Thank you, Frank - you've been always helpful. I'll keep this post in my "collections" Smile

Take care,
_________________
Regards,
Anuj
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group