View previous topic :: View next topic |
Author |
Message |
ranga_subham Intermediate

Joined: 31 Jan 2006 Posts: 255 Topics: 72
|
Posted: Thu Apr 08, 2010 2:40 pm Post subject: Match 2 Files and Create a Common file with matching records |
|
|
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 |
|
 |
Frank Yaeger Sort Forum Moderator

Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
|
Posted: Thu Apr 08, 2010 3:32 pm Post subject: |
|
|
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 |
|
 |
papadi Supermod
Joined: 20 Oct 2009 Posts: 594 Topics: 1
|
Posted: Thu Apr 08, 2010 3:38 pm Post subject: |
|
|
Which sort product is used on your system? _________________ All the best,
di |
|
Back to top |
|
 |
ranga_subham Intermediate

Joined: 31 Jan 2006 Posts: 255 Topics: 72
|
Posted: Thu Apr 08, 2010 3:47 pm Post subject: Thx |
|
|
Thank you Frank. _________________ Ranga
*****
None of us is as smart as all of us - Ken Blanchard |
|
Back to top |
|
 |
Sqlcode Intermediate
Joined: 15 Dec 2006 Posts: 157 Topics: 38
|
Posted: Wed Apr 14, 2010 10:08 am Post subject: |
|
|
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 |
|
 |
Frank Yaeger Sort Forum Moderator

Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
|
Posted: Wed Apr 14, 2010 12:02 pm Post subject: |
|
|
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 |
|
 |
Sqlcode Intermediate
Joined: 15 Dec 2006 Posts: 157 Topics: 38
|
Posted: Wed Apr 14, 2010 12:35 pm Post subject: |
|
|
Frank,
Thanks for the quick response and explanation.
Thanks, |
|
Back to top |
|
 |
ranga_subham Intermediate

Joined: 31 Jan 2006 Posts: 255 Topics: 72
|
Posted: Tue May 04, 2010 6:15 am Post subject: |
|
|
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 |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12382 Topics: 75 Location: San Jose
|
Posted: Tue May 04, 2010 10:41 am Post subject: |
|
|
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 |
|
 |
ranga_subham Intermediate

Joined: 31 Jan 2006 Posts: 255 Topics: 72
|
Posted: Tue May 04, 2010 11:21 am Post subject: thx |
|
|
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 |
|
 |
Anuj Dhawan Intermediate
Joined: 19 Jul 2007 Posts: 298 Topics: 7 Location: Mumbai,India
|
Posted: Wed May 05, 2010 3:41 am Post subject: |
|
|
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 |
|
 |
Frank Yaeger Sort Forum Moderator

Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
|
Posted: Wed May 05, 2010 11:32 am Post subject: |
|
|
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 |
|
 |
Anuj Dhawan Intermediate
Joined: 19 Jul 2007 Posts: 298 Topics: 7 Location: Mumbai,India
|
Posted: Thu May 06, 2010 4:05 am Post subject: |
|
|
Thank you, Frank - you've been always helpful. I'll keep this post in my "collections"
Take care, _________________ Regards,
Anuj |
|
Back to top |
|
 |
|
|