View previous topic :: View next topic
|
Author |
Message |
mallik4u
New User
Joined: 17 Sep 2008 Posts: 75 Location: bangalore
|
|
|
|
Hi,
I have following requirement:
Input File1:
ACCT1, 123
ACCT2, 124
Input File2:
ABC
BBC
Output:
ACCT1, ABC, 123
ACCT1, BBC, 123
ACCT2, ABC, 124
ACCT2, BBC, 124
As of now we are planning to write a COBOL program for this task. But we would like to know is there any SORT feature with which we can accoplish.
Please note that there is no common field in these files.
Thanks,
Mallik |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
More than one way.
How many records are on the second file? |
|
Back to top |
|
|
mallik4u
New User
Joined: 17 Sep 2008 Posts: 75 Location: bangalore
|
|
|
|
Thanks for the quick reply.
I have 600 records in first file. In the second file i have 800 records. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
So you want to end up with 4.8m records?
You do a JOINKEYS. With JNF1CNTL extend the record to have a fixed one-byte value of (it doesn't matter what). With JNF2CNTL extend the other record to have the same fixed new value. They need not be in the same position.
Then do the JOINKEYS on that value. Every record on file 1 will be matched to every record on file 2. You use your REFORMAT statement to format the data how you want. Done. |
|
Back to top |
|
|
mallik4u
New User
Joined: 17 Sep 2008 Posts: 75 Location: bangalore
|
|
|
|
Is it possible to match 1 record from File1 with all records in File2 using JOINKEYs? |
|
Back to top |
|
|
magesh23586
Active User
Joined: 06 Jul 2009 Posts: 213 Location: Chennai
|
|
|
|
Code for you...
As Bill mentioned you need to overlay a space in both the input file while doing the join with datasets. In the below example 13,1 has spaces already hence I didn't overlay.
Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTJNF1 DD *
ACCT1, 123
ACCT2, 124
//SORTJNF2 DD *
ABC
BBC
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
JOINKEYS FILE=F1,FIELDS=(13,1,A),SORTED,NOSEQCK
JOINKEYS FILE=F2,FIELDS=(13,1,A),SORTED,NOSEQCK
REFORMAT FIELDS=(F1:1,7,F2:1,5,F1:8,3)
//JNF2CNTL DD *
INREC OVERLAY(4:C', ')
//*
|
Hope this helps. |
|
Back to top |
|
|
mallik4u
New User
Joined: 17 Sep 2008 Posts: 75 Location: bangalore
|
|
|
|
Thank you very much Bill & Magesh for your time and help.
This solution works for us. |
|
Back to top |
|
|
|