IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Matching keys at different locations with duplicates in one


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
suraaj

New User


Joined: 16 Apr 2009
Posts: 69
Location: Canada

PostPosted: Thu May 02, 2013 9:01 pm
Reply with quote

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
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Thu May 02, 2013 9:37 pm
Reply with quote

suraaj wrote:
It doesnt work.

How does it not work?
Back to top
View user's profile Send private message
suraaj

New User


Joined: 16 Apr 2009
Posts: 69
Location: Canada

PostPosted: Thu May 02, 2013 9:38 pm
Reply with quote

A minor correction, the first file is 4500 characters long and the second file is 9 character long.
Back to top
View user's profile Send private message
suraaj

New User


Joined: 16 Apr 2009
Posts: 69
Location: Canada

PostPosted: Thu May 02, 2013 10:17 pm
Reply with quote

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
View user's profile Send private message
suraaj

New User


Joined: 16 Apr 2009
Posts: 69
Location: Canada

PostPosted: Thu May 02, 2013 11:53 pm
Reply with quote

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
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Fri May 03, 2013 12:54 am
Reply with quote

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
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Fri May 03, 2013 12:12 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri May 03, 2013 2:19 pm
Reply with quote

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
View user's profile Send private message
suraaj

New User


Joined: 16 Apr 2009
Posts: 69
Location: Canada

PostPosted: Fri May 03, 2013 6:46 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri May 03, 2013 7:07 pm
Reply with quote

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
View user's profile Send private message
suraaj

New User


Joined: 16 Apr 2009
Posts: 69
Location: Canada

PostPosted: Fri May 03, 2013 11:12 pm
Reply with quote

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
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri May 03, 2013 11:15 pm
Reply with quote

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
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri May 03, 2013 11:22 pm
Reply with quote

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
View user's profile Send private message
suraaj

New User


Joined: 16 Apr 2009
Posts: 69
Location: Canada

PostPosted: Sat May 04, 2013 1:42 am
Reply with quote

Thats a typo... icon_sad.gif

Though I am in learning phase....
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Use input file with OMIT rcd keys? DFSORT/ICETOOL 15
No new posts Rexx pattern matching on PS qualifer ... CLIST & REXX 1
No new posts How to remove block of duplicates DFSORT/ICETOOL 8
This topic is locked: you cannot edit posts or make replies. Compare files with duplicates in one ... DFSORT/ICETOOL 11
No new posts File matching functionality in Easytr... DFSORT/ICETOOL 14
Search our Forums:

Back to Top