|
View previous topic :: View next topic
|
| Author |
Message |
suraaj
New User
.jpg)
Joined: 16 Apr 2009 Posts: 69 Location: Canada
|
|
|
|
I have two files of record lengths 9 and 4500, I want to check if the 9 character field in file1 is present in file2 at position 1600 of the second file
I want the unmatched value from file 2 only to be written to another file. The values in file 1 are unique whereas the values in file1 can be duplicates. It doesnt work. Please help
I used the sortcard as below:
| Code: |
JOINKEYS F1=IN1,FIELDS=(1600,9,A)
JOINKEYS F2=IN2,FIELDS=(1,9,A)
JOIN UNPAIRED,F2,ONLY
OPTION COPY |
|
|
| Back to top |
|
 |
Akatsukami
Global Moderator

Joined: 03 Oct 2009 Posts: 1787 Location: Bloomington, IL
|
|
|
|
| suraaj wrote: |
| It doesnt work. |
How does it not work? |
|
| Back to top |
|
 |
suraaj
New User
.jpg)
Joined: 16 Apr 2009 Posts: 69 Location: Canada
|
|
|
|
| A minor correction, the first file is 4500 characters long and the second file is 9 character long. |
|
| Back to top |
|
 |
suraaj
New User
.jpg)
Joined: 16 Apr 2009 Posts: 69 Location: Canada
|
|
|
|
It works after I added the SORTED,NOSEQCK to both the files which makes the sortcard as
| Code: |
JOINKEYS F1=IN1,FIELDS=(1600,9,A),SORTED,NOSEQCK
JOINKEYS F2=IN2,FIELDS=(1,9,A),SORTED,NOSEQCK
JOIN UNPAIRED,F2,ONLY
OPTION COPY
|
|
|
| Back to top |
|
 |
suraaj
New User
.jpg)
Joined: 16 Apr 2009 Posts: 69 Location: Canada
|
|
|
|
| Code: |
JOINKEYS FILE=F1,FIELDS=(1600,9,A),SORTED,NOSEQCK
JOINKEYS FILE=F2,FIELDS=(1,9,A),SORTED,NOSEQCK
JOIN UNPAIRED,F1,F2
REFORMAT FIELDS=(F1:1600,9,F2:1,9,?)
OPTION COPY
OUTFIL FNAMES=F1ONLY,INCLUDE=(19,1,CH,EQ,C'1'),
BUILD=(1,9)
OUTFIL FNAMES=F2ONLY,INCLUDE=(35,1,CH,EQ,C'2'),
BUILD=(1,9)
OUTFIL FNAMES=BOTH,INCLUDE=(35,1,CH,EQ,C'B'),
BUILD=(1,9,/,11,9)
|
I am trying to write values present in F1 alone to one file, F2 alone to another file and both files to another file. I am using the above sort card. I am getting the error as
ICE414A 0 SORTJNF1 (F1) KEY FIELD END AT 1608 IS BEYOND LENGTH OF 9
Please advise. |
|
| Back to top |
|
 |
Akatsukami
Global Moderator

Joined: 03 Oct 2009 Posts: 1787 Location: Bloomington, IL
|
|
|
|
| Although I am not a DFSORT maven, does not this message suggest to you that perhaps the wrong data sets are assigned to the SORTJNFn files? |
|
| Back to top |
|
 |
mistah kurtz
Active User
Joined: 28 Jan 2012 Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
|
|
|
|
First check if you are using correct DD-FIle name combination and then try with below sort card:
| Code: |
JOINKEYS FILE=F1,FIELDS=(1600,9,A),SORTED,NOSEQCK
JOINKEYS FILE=F2,FIELDS=(1,9,A),SORTED,NOSEQCK
JOIN UNPAIRED,F1,F2
REFORMAT FIELDS=(F1:1600,9,F2:1,9,?)
OPTION COPY
OUTFIL FNAMES=F1ONLY,INCLUDE=(19,1,CH,EQ,C'1'),BUILD=(1,9)
OUTFIL FNAMES=F2ONLY,INCLUDE=(19,1,CH,EQ,C'2'),BUILD=(10,9)
OUTFIL FNAMES=BOTH,INCLUDE=(19,1,CH,EQ,C'B'),BUILD=(1,9,C'/',11,9) |
If it does not work, post sample input and expected output data. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
You really should be able to fix that yourself without asking. The message is explicit, and the 9 must mean something to you.
I've changed the third OUTFIL to use SAVE, which means "put on this OUTFIL all records which do not appear on another OUTFIL".
I've changed the 11,9 on that OUTFIL to 10,9, assuming that you want the full information, not the last eight bytes plus the match marker.
On that OUTFIL, other than looking at odd/even "line number", you have no clue as to which is from what input. However, since they should be the same, it shouldn't matter, and perhaps you only need to output one of them :-)
| Code: |
JOINKEYS FILE=F1,FIELDS=(1600,9,A),SORTED,NOSEQCK
JOINKEYS FILE=F2,FIELDS=(1,9,A),SORTED,NOSEQCK
JOIN UNPAIRED,F1,F2
REFORMAT FIELDS=(F1:1600,9,F2:1,9,?)
OPTION COPY
OUTFIL FNAMES=F1ONLY,INCLUDE=(19,1,CH,EQ,C'1'),BUILD=(1,9)
OUTFIL FNAMES=F2ONLY,INCLUDE=(19,1,CH,EQ,C'2'),BUILD=(10,9)
OUTFIL FNAMES=BOTH,SAVE,BUILD=(1,9,C'/',10,9) |
|
|
| Back to top |
|
 |
suraaj
New User
.jpg)
Joined: 16 Apr 2009 Posts: 69 Location: Canada
|
|
|
|
My badf and apologies for not seeing at the issue myself. This works now.
Another question pertaining to the same, since there are duplicates present at the 4500 length file I am getting the duplicates in the "BOTH" file. Is there a way that I can get the duplicates removed and just get the count of how many times each are repeated.Kindly help |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| Yes, if you look at OUTFIL in the manual, specifically SECTIONS, TRAILER3, COUNT. If you use REMOVECC and NODETAIL you should get what I think you want. If you don't, show the sample input, and expected output, and what you have tried. |
|
| Back to top |
|
 |
suraaj
New User
.jpg)
Joined: 16 Apr 2009 Posts: 69 Location: Canada
|
|
|
|
Thanx Bill. I got it.
| Code: |
JOINKEYS FILE=F1,FIELDS=(1600,9,A),SORTED,NOSEQCK
JOINKEYS FILE=F2,FIELDS=(1,9,A),SORTED,NOSEQCK
JOIN UNPAIRED,F1,F2
REFORMAT FIELDS=(F1:1600,9,F2:1,9,?)
OPTION COPY
OUTFIL FNAMES=BOTH,INCLUDE=(19,1,CH,EQ,C'B'),BUILD=(1,9,C'/',10,9),
REMOVECC,NODETAIL,
SECTIONS=(1,2,
TRAILER3=(1,9,COUNT=(M10,LENGTH=8))),
HEADER1=('CODE COUNT')
|
This is the code that I used to get the result. Please advise if there is something more that can be done in the code to improve efficiency |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
If you just need the keys why bother reading the entire 1600 byte F1 record? use JNF1 and JNF2 to read only the fields you interested.
As you mentioned that you have duplicates in BOTH file, I am assuming that you also might have duplicates on the non matching keys. Use the following control cards that will remove duplicates in ALL the files and give you the desired results.
| Code: |
//SYSIN DD *
OPTION COPY
JOINKEYS F1=INA,FIELDS=(1,9,A),SORTED,NOSEQCK
JOINKEYS F2=INB,FIELDS=(1,9,A),SORTED,NOSEQCK
JOIN UNPAIRED
REFORMAT FIELDS=(F1:1,9,?,F2:1,9)
INREC IFOUTLEN=10,IFTHEN=(WHEN=(10,1,CH,EQ,C'2'),BUILD=(11,9,10,1))
OUTFIL FNAMES=F1ONLY,INCLUDE=(10,1,CH,EQ,C'1'),
BUILD=(9X),REMOVECC,NODETAIL,SECTIONS=(1,9,TRAILER3=(1,9))
OUTFIL FNAMES=F2ONLY,INCLUDE=(10,1,CH,EQ,C'2'),
BUILD=(9X),REMOVECC,NODETAIL,SECTIONS=(1,9,TRAILER3=(1,9))
OUTFIL FNAMES=BOTH,SAVE,
BUILD=(9X),REMOVECC,NODETAIL,SECTIONS=(1,9,TRAILER3=(1,9))
//*
//JNF1CNTL DD *
INREC BUILD=(1600,9)
//*
//JNF2CNTL DD *
INREC BUILD=(1,9)
//* |
|
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| suraaj wrote: |
Thanx Bill. I got it.
| Code: |
JOINKEYS FILE=F1,FIELDS=(1600,9,A),SORTED,NOSEQCK
JOINKEYS FILE=F2,FIELDS=(1,9,A),SORTED,NOSEQCK
JOIN UNPAIRED,F1,F2
REFORMAT FIELDS=(F1:1600,9,F2:1,9,?)
OPTION COPY
OUTFIL FNAMES=BOTH,INCLUDE=(19,1,CH,EQ,C'B'),BUILD=(1,9,C'/',10,9),
REMOVECC,NODETAIL,
SECTIONS=(1,2,
TRAILER3=(1,9,COUNT=(M10,LENGTH=8))),
HEADER1=('CODE COUNT')
|
This is the code that I used to get the result. Please advise if there is something more that can be done in the code to improve efficiency |
huh?
Why are you using sections for 1,2? when your key has a length of 9 bytes? And the count you get is totally wrong.
Lets say you 10 duplicates for a key in file1 and the same key have 20 duplicates in file2, then join keys would have produced 10 X 20 = 200 records for that key. With your job you might get 200 as count which is totally wrong. You need to better understand what joinkeys does |
|
| Back to top |
|
 |
suraaj
New User
.jpg)
Joined: 16 Apr 2009 Posts: 69 Location: Canada
|
|
|
|
Thats a typo...
Though I am in learning phase.... |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|