View previous topic :: View next topic
Author
Message
magesh23586 Active User Joined: 06 Jul 2009Posts: 213 Location: Chennai
Hi,
I need to merge two columns from couple of files without comparing, I know files are in same sequence , I need to overlay some values from file2.
I tried with joinkey, but it asking me for joinkey and its comparing and changing the sequence of the file.
Requirement is to concatenate/merge (F1:1,93,F2:94,25,F1:119,13)
F1 is file1
F2 is File2
need not compare, need not sort, just overlay these F2 records
Please help me on this.
Code:
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTJNF1 DD DSN=zxttdd.a1,DISP=SHR
//SORTJNF2 DD DSN=zxttdd.b1,DISP=SHR
//SORTOUT DD DSN=zxttdd.c1,DISP=OLD
//SYSIN DD *
* CONTROL STATEMENTS FOR JOINKEYS APPLICATION
JOINKEYS FILE=F1,FIELDS=(67,17,A)
JOINKEYS FILE=F2,FIELDS=(67,17,A)
REFORMAT FIELDS=(F1:1,93,F2:94,25,F1:119,13)
* CONTROL STATEMENTS FOR MAIN TASK (JOINED RECORDS)
SORT FIELDS=COPY
/*
regards,
Magesh
Back to top
Pandora-Box Global Moderator Joined: 07 Sep 2006Posts: 1592 Location: Andromeda Galaxy
Why do you dont want to use Joinkeys?
Is that the requirement to be done without Joinkeys?
Back to top
magesh23586 Active User Joined: 06 Jul 2009Posts: 213 Location: Chennai
Joinkeys is sorting the file, hence sequence of the file is affected , I don't want to compare actually and I don't know the way to directly concatenate two columns. Hence I tried joinkey, Is there any way to just concatenate two columns from two different files, Sequence should be same as the input file.
Regards,
Magesh
Back to top
Pandora-Box Global Moderator Joined: 07 Sep 2006Posts: 1592 Location: Andromeda Galaxy
What you could do is
use JNFCNTLn
To Add sequence number to both the files and join based on the sequence
Or
Did you try SORTED??
Code:
JOINKEYS FILE=F1,FIELDS=(67,17,A),SORTED
JOINKEYS FILE=F2,FIELDS=(67,17,A),SORTED
Back to top
magesh23586 Active User Joined: 06 Jul 2009Posts: 213 Location: Chennai
How do I do this, It would be great if you could share the code.
Back to top
magesh23586 Active User Joined: 06 Jul 2009Posts: 213 Location: Chennai
JOINKEYS FILE=F1,FIELDS=(67,17,A),SORTED is failed because joinkey I mentioned is out of sequence
Back to top
expat Global Moderator Joined: 14 Mar 2007Posts: 8797 Location: Welsh Wales
Not sure if it will override the sequence checking, but you could try
SORTED,NOSEQCK instead of SORTED
Back to top
magesh23586 Active User Joined: 06 Jul 2009Posts: 213 Location: Chennai
Still the sequence of the output file is changed
I think it is because of =(67,17,A) is there any way to avoid this 'A'
Back to top
Pandora-Box Global Moderator Joined: 07 Sep 2006Posts: 1592 Location: Andromeda Galaxy
Check this example
Code:
//INA DD *
DDD FIL1
AAA FIL1
BBB FIL1
CCC FIL1
//INB DD *
DDD FIL2
AAA FIL2
BBB FIL2
CCC FIL2
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
JOINKEYS F1=INA,FIELDS=(81,3,A)
JOINKEYS F2=INB,FIELDS=(81,3,A)
REFORMAT FIELDS=(F1:1,10,F2:1,10)
//JNF1CNTL DD *
INREC OVERLAY=(81:SEQNUM,3,ZD)
//JNF2CNTL DD *
INREC OVERLAY=(81:SEQNUM,3,ZD)
Output
Code:
DDD FIL1 DDD FIL2
AAA FIL1 AAA FIL2
BBB FIL1 BBB FIL2
CCC FIL1 CCC FIL2
Back to top
magesh23586 Active User Joined: 06 Jul 2009Posts: 213 Location: Chennai
You example will work, if we have an empty column, Both of my files have complete data, no empty column, I cant give the length beyond the file RECL.
Regards,
Magesh
Back to top
expat Global Moderator Joined: 14 Mar 2007Posts: 8797 Location: Welsh Wales
I suggest that you try the code before saying it will not work for you.
Why do you think that you need a "empty column" ?
Back to top
Pandora-Box Global Moderator Joined: 07 Sep 2006Posts: 1592 Location: Andromeda Galaxy
Quote:
You example will work, if we have an empty column, Both of my files have complete data, no empty column, I cant give the length beyond the file RECL.
Can you please try to make the code as per your input data using my example?
Let us know the output that you got
Please do not comment without trying it
Back to top
magesh23586 Active User Joined: 06 Jul 2009Posts: 213 Location: Chennai
Got the solution
From File1 I don't requires 94,25 hence I can overlay the sequence number for file1 in 94th position, llly for file2 1 to 93 I can use for overlay.
Created the below code, It worked fine, Thanks Expat and Pandora-Box
Code:
//SYSIN DD *
* CONTROL STATEMENTS FOR JOINKEYS APPLICATION
JOINKEYS FILE=F1,FIELDS=(94,7,A),SORTED,NOSEQCK
JOINKEYS FILE=F2,FIELDS=(1,7,A),SORTED,NOSEQCK
REFORMAT FIELDS=(F1:1,93,F2:94,25,F1:119,13)
* CONTROL STATEMENTS FOR MAIN TASK (JOINED RECORDS)
SORT FIELDS=COPY
/*
//JNF1CNTL DD *
INREC OVERLAY=(94:SEQNUM,7,ZD)
//JNF2CNTL DD *
INREC OVERLAY=(1:SEQNUM,7,ZD)
/*
Back to top
dick scherrer Moderator Emeritus Joined: 23 Nov 2006Posts: 19244 Location: Inside the Matrix
Hello,
You still do not understand . . .
You Need to try the posted code. Not just throw something else together. Your "solution" will not work in every case. The sample posted will.
The example builds a sequence number beyond the end of the input record and discards this in the reformat.
If you are unwilling to try the code provided, why ask in the first place?
If you intend to use the "works for this format only" code you showed, you have wasted everyone's time . . .
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
Well done for spotting that you can re-use part of the F1 record.
You can further cut down your F1 and your F2 just to the minimum (only the data you need). Might not make much difference this time, but it is a good habit to get in to, as if you needed to have the JOINKEYS do a SORT (for a different requirement), the less data the better.
Back to top
Please enable JavaScript!