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

Match or compare two files in VB Format


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

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

PostPosted: Thu Nov 03, 2016 7:41 pm
Reply with quote

Hi,

For files FB 80 I can compare 2 files and split for in both, in first, in second by:
Code:

  JOINKEYS FILE=F1,FIELDS=(1,10,A)                       
  JOINKEYS FILE=F2,FIELDS=(1,10,A)                       
  JOIN UNPAIRED,F1,F2                                     
  REFORMAT FIELDS=(F1:1,80,F2:1,80,?)                     
  OPTION COPY                                             
 OUTFIL FNAMES=BOTH,INCLUDE=(161,1,CH,EQ,C'B'),           
 BUILD=(1,80)                                             
 OUTFIL FNAMES=FIRST,INCLUDE=(161,1,CH,EQ,C'1'),         
 BUILD=(1,80)                                             
 OUTFIL FNAMES=SECOND,INCLUDE=(161,1,CH,EQ,C'2'),         
 BUILD=(81,80)                                           


but how I can do it for files VB 80?
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Thu Nov 03, 2016 8:41 pm
Reply with quote

Quote:
z/OS DFSORT >> z/OS DFSORT Application Programming Guide >> Using a JOINKEYS application for joining two files >> JOINKEYS statements
mentions what needs to be considered while handling variable length records in a JOIN application. Please read through, try it out and get back if you come across something unexpected. Or search the forum for working examples.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Thu Nov 03, 2016 9:59 pm
Reply with quote

BTW also searching the forum would have been a good start

search word ==> JOINKEYS
forum ==> dfsort
author Frank Yaeger

and You would have landed here ( one of the many replies )

ibmmainframes.com/viewtopic.php?t=53484&highlight=joinkeys

the general rule is to take into account the RDW and add 4 to all field positions
but I am not a sort expert
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: Thu Nov 03, 2016 10:42 pm
Reply with quote

As long as at least one of your JOINKEYS files is of variable-length records, then you can create a variable-length REFORMAT record.

On the other hand, even if both your files are variable-length records you don't have to create a variable-length REFORMAT records.

You create a variable-length REFORMAT record by including the RDW from one input file which contains variable-length records.

Code:
REFORMAT FIELDS=(F2:1,4,F1:5,80,F2:5)


You have to consider short records (they will be padded, you have control over with what) and may need a VLTRIM on some of the OUTFILs.
Back to top
View user's profile Send private message
anatol

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

PostPosted: Thu Nov 03, 2016 10:55 pm
Reply with quote

Thank you, Bill ... unfortunately both files are VB .. with
REFORMAT FIELDS=(F2:1,4,F1:5,80,F2:5) I can get VB records from F2 , but not from F1 ... so I think I have to use 3 steps to get in both, in first, in second
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Thu Nov 03, 2016 11:15 pm
Reply with quote

Quote:
so I think I have to use 3 steps to get in both, in first, in second
I don't think you need 3 steps to do this. Did you try using the "?". Can you show what have you tried.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Thu Nov 03, 2016 11:45 pm
Reply with quote

Quote:
I cannot create VB for file 1 and VB from file 2
This statement is not true. So far you have posted only what you tried with FB data sets nothing with VB. So no point in referring to your initial post which is regarding your FB test.

hmmm... I think we are on the verge of getting locked. icon_smile.gif
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Thu Nov 03, 2016 11:53 pm
Reply with quote

I just ran a test with VB input, and all the 3 outputs - VB again. I don't see a problem here.
Back to top
View user's profile Send private message
anatol

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

PostPosted: Fri Nov 04, 2016 12:04 am
Reply with quote

wow Arun, could you please show what you use for test?
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 Nov 04, 2016 12:26 am
Reply with quote

Did anyone read my post?

Try this:

Code:
 REFORMAT FIELDS=(F1:1,4,F1:5,F2:5)


Use that for a JOINKEYS with F1,F2,ONLY and see what you get.

Otherwise, I've already shown a REFORMAT which will get you variable-length records, some of which you'll have to later VLTRIM.
Back to top
View user's profile Send private message
anatol

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

PostPosted: Fri Nov 04, 2016 1:01 am
Reply with quote

ok, actual file is 1000 , not as I ask before .I've used
Code:

  JOINKEYS FILE=F1,FIELDS=(9,71,A)                 
  JOINKEYS FILE=F2,FIELDS=(9,71,A)                 
  JOIN UNPAIRED,F1,F2,ONLY                         
   REFORMAT FIELDS=(F1:1,4,?,F1:5,F2:5)           
  SORT FIELDS=COPY                                 
 OUTFIL FNAMES=INBOTHF,INCLUDE=(5,1,CH,EQ,C'B')   
 OUTFIL FNAMES=INF1ONLY,INCLUDE=(5,1,CH,EQ,C'1')   
 OUTFIL FNAMES=INF2ONLY,INCLUDE=(5,1,CH,EQ,C'2')   

in first and in second file are good, but nothing in file both
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Fri Nov 04, 2016 1:07 am
Reply with quote

Code:
JOIN UNPAIRED,F1,F2,ONLY
You have included ONLY NON MATCHING records.

You need
Code:
JOIN UNPAIRED
OR
Code:
JOIN UNPAIRED,F1,F2
to be able to output matched records too.

The other problem here is you will not know where exactly the file2 record begins, depends on how long is the "current" file1 record which is also of variable length. So BUILDing each output would be tricky.
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 Nov 04, 2016 1:13 am
Reply with quote

I'm going to take a heavy axe to this topic shortly. Anyone want to complain, don't bother.

Anatol,

I wasn't suggesting that code for you to use, because you want matches. F1,F2,ONLY will only get you mismatches. If you take off the ,ONLY you'll get REFORMAT records for B, but they would need some work because the F2 data would start immediately after the end of the F1 data.

Your best option is RDW,"fixed" data from one file,"variable" data from the other. Then, on any OUTFIL where the fixed data is used for output, you VLTRIM (be careful not to trim a vital value, so know what data can be in the last position).
Back to top
View user's profile Send private message
anatol

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

PostPosted: Fri Nov 04, 2016 1:21 am
Reply with quote

Thank you all ... I think we all tired of this topic ... it was good learning .. I like sort icon_biggrin.gif
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Fri Nov 04, 2016 4:38 pm
Reply with quote

Quote:
Your best option is RDW,"fixed" data from one file,"variable" data from the other. Then, on any OUTFIL where the fixed data is used for output, you VLTRIM (be careful not to trim a vital value, so know what data can be in the last position).



I was going to say that is what I said anatol should do several posts back.

But wait, my posts are gone. icon_sad.gif

It kinda hurts when you spend time responding, and it gets deleted.

Yea, I know, there were some 'off topic' bantering going on, but most of my posts were on point.

Guess we will never know.
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 Populate last day of the Month in MMD... SYNCSORT 2
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Need to convert date format DFSORT/ICETOOL 20
Search our Forums:

Back to Top