MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

File comparison
Goto page 1, 2  Next
 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
lacoe1
Beginner


Joined: 24 Feb 2005
Posts: 33
Topics: 17

PostPosted: Thu Nov 08, 2007 6:14 pm    Post subject: File comparison Reply with quote

I have 2 files - A & B, need to compare these files to see if a particular field in each of these files are same. If same then I need to just write out file B. Is there any tool that can do this or need to write a quick program for this.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Nov 08, 2007 6:38 pm    Post subject: Reply with quote

You haven't given enough information. Please show an example of the records in each input file (relevant fields only) and what you want for output. If there are duplicates within either file, show that in your example. Give the RECFM and LRECL of the input files. Give the starting position, length and format of all relevant fields.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
lacoe1
Beginner


Joined: 24 Feb 2005
Posts: 33
Topics: 17

PostPosted: Thu Nov 08, 2007 7:23 pm    Post subject: Reply with quote

Ok, this is my situation.

DCB=(RECFM=VB,LRECL=4030,BLKSIZE=0)

The first 32 bytes is fixed (shown in bold below), rest is variable length.

Here is a picture of the file for the first 84 bytes.
03362000800033331520070824E4CE4850104 ........%.*..WIESELTHIER,J..

Both files are same structure. Need to just check
Position 19, Length 11 (above has data 20070824E4C - all char)

If both files (A & B) have same information in that field, then, write output is file B.
If different, then output file should be blank.

There are no duplicates records within either file.

** just informational - In the above record position 6-8 which is 336 says the variable portion length is 336
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Nov 08, 2007 7:40 pm    Post subject: Reply with quote

Quote:
If both files (A & B) have same information in that field, then, write output is file B.


Are you comparing record-by-record, that is, compare record1 of file1 to record1 of file2, compare record2 of file1 to record2 of file2, etc. Or are you comparing by key, that is, if any record in file1 has the same key as any record in file2?

Quote:
Need to just check position 19


I assume when you say position 19, you are not counting the RDW in positions 1-4 so you really mean position 23 ... right?

Quote:
If different, then output file should be blank.


What do you mean by this? Do you mean the record should not be in the output file or do you mean something else?

When I asked you to
Quote:
Please show an example of the records in each input file (relevant fields only) and what you want for output.
I didn't mean for you to show one input record in one file and no output records. That really doesn't help. If you can't show a proper example of several records in each input file and the expected output (just the bytes up to and including the key field will do), then I can't give you a solution.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
lacoe1
Beginner


Joined: 24 Feb 2005
Posts: 33
Topics: 17

PostPosted: Thu Nov 08, 2007 7:58 pm    Post subject: Reply with quote

Quote:
Are you comparing record-by-record, that is, compare record1 of file1 to record1 of file2, compare record2 of file1 to record2 of file2, etc. Or are you comparing by key, that is, if any record in file1 has the same key as any record in file2?


For the field I mentioned, each file should have the same information though out the file. So just reading the 1st record and comparing that field from the 2 files is enough, donot need to compare every record.

Quote:
I assume when you say position 19, you are not counting the RDW in positions 1-4 so you really mean position 23 ... right?


Yes

Quote:
What do you mean by this? Do you mean the record should not be in the output file or do you mean something else?


No record should be written out.

Quote:
I didn't mean for you to show one input record in one file and no output records. That really doesn't help. If you can't show a proper example of several records in each input file and the expected output (just the bytes up to and including the key field will do), then I can't give you a solution.


Case1
File A Position 23,11bytes

20070824E4C

File B Position 23,11 bytes

20070824E4C

Write out all records from B to output

Case2
File A Position 23,11bytes

20070824E4C

File B Position 23,11 bytes

20070829C2I

Output is blank.



Its ok if this info is not enough, a program can be written - I was thinking for an alternate method.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Fri Nov 09, 2007 11:32 am    Post subject: Reply with quote

Well, I think you're saying you want to take the value from the first record in file1 and use it to select the records from file2 for output. If so, then you can use this DFSORT job:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file1 (VB)
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN    DD    *
  OPTION COPY,STOPAFT=1
* Create DFSORT Symbol from first record of file1 as:
* TARG,'value'
  OUTFIL VTOF,BUILD=(C'TARG,''',23,11,C'''',80:X)
/*
//S2    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=...  input file2 (VB)
//SORTOUT DD DSN=...  output file (VB)
//SYSIN    DD    *
  OPTION COPY
* Use TARG value to select records from file2 for output
  INCLUDE COND=(23,11,CH,EQ,TARG)
/*

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
lacoe1
Beginner


Joined: 24 Feb 2005
Posts: 33
Topics: 17

PostPosted: Fri Nov 09, 2007 4:20 pm    Post subject: Reply with quote

Thank you.
Back to top
View user's profile Send private message
mf_user
Intermediate


Joined: 01 Jun 2003
Posts: 372
Topics: 105

PostPosted: Thu Jan 22, 2009 5:21 am    Post subject: Reply with quote

Frank, I understand it like SYMNAMES is useful to compare only a single record but not on multiple records ?

Please suggest.

Thanks.
_________________
MF
==
Any training that does not include the emotions, mind and body is incomplete; knowledge fades without feeling.
==
Back to top
View user's profile Send private message Send e-mail
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Jan 22, 2009 11:40 am    Post subject: Reply with quote

I don't understand what you mean. SYMNAMES can contain multiple symbols. INCLUDE works on multiple records. If an input file has multiple records with a constant on each one, OUTFIL can be used to build a symbol for each constant on a separate line for SYMNAMES.

I showed the OP a job for the example given. If you want to do something else, you need to explain what you want to do with an example.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mf_user
Intermediate


Joined: 01 Jun 2003
Posts: 372
Topics: 105

PostPosted: Fri Jan 23, 2009 4:01 am    Post subject: Reply with quote

Frank,

My look up file (LRECL=80, RECFM=FB):

Code:

163451
164211
164212
164213


The file (LRECL=260, RECFM=FB) needs to be searched for records to extract:

Code:

NFV1150002089000001634512009
NFV1150002089000001634512009
NFV1150002090000001151962009
NFW1JZ0002929000001642112009
NFW1JZ0002929000001642112009
NFW1JZ0002930000001138662009
NGJ1V00000590000001642132009
NGJ1V00000590000001642132009
NGJ1V00000591000001191662009


Required Output:

Code:

NFV1150002089000001634512009
NFW1JZ0002929000001642112009
NGJ1V00000590000001642132009


Thanks.
_________________
MF
==
Any training that does not include the emotions, mind and body is incomplete; knowledge fades without feeling.
==
Back to top
View user's profile Send private message Send e-mail
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Fri Jan 23, 2009 11:33 am    Post subject: Reply with quote

File1 has 163451 and file2 has two records that have 163451 in position 19-24 and you show one of those file2 records for output. So can I surmise from this that you want the first record in file2 that has a match in file1 (it would have been nice if you actually gave the "rules" for what you want to do). Or do you want something else (describe in detail).

What is the maximum number of records you would have in file1?
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mf_user
Intermediate


Joined: 01 Jun 2003
Posts: 372
Topics: 105

PostPosted: Fri Jan 23, 2009 10:11 pm    Post subject: Reply with quote

File-2 will always have duplicates. So, I want the first duplicate only to be written to the output file. The maximum entries in File-1 will be not more than 7 and we don't have control over it as it is maintained by end user.

Thanks.
_________________
MF
==
Any training that does not include the emotions, mind and body is incomplete; knowledge fades without feeling.
==
Back to top
View user's profile Send private message Send e-mail
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Sat Jan 24, 2009 11:17 am    Post subject: Reply with quote

Here's a DFSORT job that will do what you asked for. I assumed your input records were already in sorted order. If not change the //SORTIN01 DD to a //SORTIN DD and change the MERGE statement to a SORT statement.

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  lookup file (FB/80)
//SORTOUT DD DSN=&&C1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN    DD    *
  OPTION COPY
  OUTFIL REMOVECC,
    HEADER1=('  INCLUDE COND=(1,1,CH,NE,1,1,CH,OR,'),
    BUILD=(C'  19,6,CH,EQ,C''',1,6,C''',OR,',80:X),
    TRAILER1=('  1,1,CH,NE,1,1,CH)')
/*
//S2 EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN01 DD DSN=...  input file (FB/260)
//SORTOUT DD DSN=...  output file (FB/260)
//SYSIN  DD DSN=&&C1,DISP=(OLD,PASS)
//       DD *
  MERGE FIELDS=(19,6,CH,A)
  OPTION EQUALS
  SUM FIELDS=NONE
/*

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mf_user
Intermediate


Joined: 01 Jun 2003
Posts: 372
Topics: 105

PostPosted: Sat Jan 24, 2009 11:42 am    Post subject: Reply with quote

Frank, Thank you very much. I was expecting usage of SYMBOLS in the solution you given.
_________________
MF
==
Any training that does not include the emotions, mind and body is incomplete; knowledge fades without feeling.
==
Back to top
View user's profile Send private message Send e-mail
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Mon Jan 26, 2009 11:10 am    Post subject: Reply with quote

The use of Symbols is NOT the best way to do that kind of thing. I gave you a more appropriate solution.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group