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

matching two different files


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
miosne
Warnings : 1

New User


Joined: 13 Mar 2006
Posts: 63
Location: italy

PostPosted: Mon Mar 13, 2006 7:46 pm
Reply with quote

I've this problem to solve.
two files with the same lenght and the same structure.
how can I extract only the different records from the first or the second file??
INREC1=(LENGHT=330)
INREC2=(LENGHT=330)
when they are different I want to save the record from INREC2....
thank you.
sorry for my english.....
Back to top
View user's profile Send private message
martin9

Active User


Joined: 01 Mar 2006
Posts: 290
Location: Basel, Switzerland

PostPosted: Mon Mar 13, 2006 7:57 pm
Reply with quote

hy miosne,

com? stai?
try the following,
make a sort step and include only those records,
which have the same contents from file1 to file2.
concatenate both files in SORTIN and make sure,
that the full record is given in your condition...

martin9
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Mon Mar 13, 2006 8:06 pm
Reply with quote

Hi miosne,

There is an excellent DFSORT Trick for the problem you are looking for...ofcourse if you use DFSORT...

You'll have to accomodate changes as per your requirements... If any problem... Get back to us...

Quote:
sorry for my english.....

I dont see any reason for that.

Regards,
Priyesh.
Back to top
View user's profile Send private message
miosne
Warnings : 1

New User


Joined: 13 Mar 2006
Posts: 63
Location: italy

PostPosted: Mon Mar 13, 2006 9:01 pm
Reply with quote

CIAO A TUTTI.....
I'm so tired.... coz I've understand the metod....
thanks a lot to all
Back to top
View user's profile Send private message
miosne
Warnings : 1

New User


Joined: 13 Mar 2006
Posts: 63
Location: italy

PostPosted: Mon Mar 13, 2006 9:23 pm
Reply with quote

the post of pryiesh "? ci? che dio fece" but
the starting conditions are not te sames... follow me :-)
INFILE1=(330)
INFILE2=(330)
SO THE MATCHING UP RECORDS ARE NOT INTERESTING, I WANNA WROTE ONLY THE DIFFERENT BYTES FROM 10,321 THAT MATCHING THE KEY 1,9 AND SAVING ONLY THE RECORDS FROM INFILE2
EXAMPLE
INFILE1
00000000SIMONE
00000001STEFANO

INFILE2
00000000SIMON1
00000001STEFANO

OUTFILE
00000000SIMON1

HOW CAN I DO IT???
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Mon Mar 13, 2006 10:46 pm
Reply with quote

Do all of the records in file1 have a matching key in file2? Or can there be records in file1 without a matching key in file2 and vice versa. If so, what do you want to do with those records?

Please give a more detailed example of your input records and what you want for output, showing all of the possible variations of matching and non-matching records.
Back to top
View user's profile Send private message
miosne
Warnings : 1

New User


Joined: 13 Mar 2006
Posts: 63
Location: italy

PostPosted: Mon Mar 13, 2006 11:13 pm
Reply with quote

yes avery key in infile1 have the same key but not also the same data, so when the condition is not verifyied i must wrote the record in outfile....

INFILE1
00000000SIMONE
00000001STEFANO

INFILE2
00000000SIMON1
00000001STEFANO

OUTFILE
00000000SIMON1
desperate househusbands
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Mon Mar 13, 2006 11:43 pm
Reply with quote

Where did the desperate househusbands record come from? I don't see it in INFILE1 or INFILE2.

Also, I forgot to ask. Can there be duplicate keys within INFILE1? Can there be duplicate keys within INFILE2? If so, please include that in your example.

And what is the RECFM and LRECL of INFILE1 and INFILE2?
Back to top
View user's profile Send private message
miosne
Warnings : 1

New User


Joined: 13 Mar 2006
Posts: 63
Location: italy

PostPosted: Mon Mar 13, 2006 11:53 pm
Reply with quote

INFILE1
LRECL=330
000000000SIMONE
000000001STEFANO
000000002ROBETRO
000000003GIORGIO
000000004ANDREA

INFILE2
LRECL=330
000000000SIMON1
000000001STEFANO
000000003GIORGIO
000000004ANDRES

OUTFILE
LRECL=330
000000000SIMON1
000000002ROBERTO
000000004ANDRES
NO DUPLICATE KEYS IN INFILE1 AND INFILE2
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Mar 14, 2006 12:15 am
Reply with quote

Quote:
when they are different I want to save the record from INREC2....


In INFILE1, you have:

000000002ROBETRO

In OUTFIL, you have:

000000002ROBERTO

I assume you meant for this to be the same record for output (ROBETRO instead of ROBERTO) as for input. But if you only want to save records from INREC2, why are you saving this record from INREC1? And what about records that are in INREC2, but not in INREC1?

I'm trying to help, but you need to be more careful in describing your requirements so I can understand what you want to do.
Back to top
View user's profile Send private message
miosne
Warnings : 1

New User


Joined: 13 Mar 2006
Posts: 63
Location: italy

PostPosted: Tue Mar 14, 2006 1:28 pm
Reply with quote

but my english not bad like then your!!!!
I'll try another time.
I'va to save the different records from INFILE2 that matching in INFILE! by the key but with the data NE so like the exmples that I've explained in the previous posts.... and like this one.....

INFILE1
LRECL=330
000000000SIMONE
000000001STEFANO
000000002ROBETRO
000000003GIORGIO
000000004ANDREA

INFILE2
LRECL=330
000000000SIMON1
000000001STEFANO
000000003GIORGIO
000000004ANDRES

OUTFILE
LRECL=330
000000000SIMON1
000000002ROBERTO
000000004ANDRES

in the outfile i want to save the records that matching between infile1 and infile 2 by the key but have the data patitions different....

thank you a lot....
Back to top
View user's profile Send private message
miosne
Warnings : 1

New User


Joined: 13 Mar 2006
Posts: 63
Location: italy

PostPosted: Tue Mar 14, 2006 2:24 pm
Reply with quote

I've make a mistake .... :-(
my english is not good like then your.... excuse me....
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Mar 14, 2006 10:05 pm
Reply with quote

You keep saying that you want to save the records from file2, but in your example output, you are saving a record from file1 (000000002ROBERTO ). So I can't figure out what you really want. You sent me an even more confusing example by e-mail - in that one, you saved one record from file1 that didn't match, but didn't save another one.

Let's try this. If you had these input records:

File1
000000000SIMONE
000000001STEFANO
000000002ROBETRO
000000003GIORGIO
000000004ANDREA
000000007FRANK

File2
000000000SIMON1
000000001STEFANO
000000003GIORGIO
000000004ANDRES
000000006CHARLIE

What would you want for output?

When I look at these input records, I see the following mismatched records:

Key 0 - in file1 and file2, so write file2 record to output
Key 2 - only in file1 - write it to output or not?
Key 4 - in file1 and file2, so write file2 record to output
Key 6 - only in file2 - write it to output or not?
Key 7 - only in file1 - write it to output or not?

Now what do you want for output and why?
Back to top
View user's profile Send private message
miosne
Warnings : 1

New User


Joined: 13 Mar 2006
Posts: 63
Location: italy

PostPosted: Tue Mar 14, 2006 10:31 pm
Reply with quote

the problem is that my english is like the english of an analphabeta man... :-(
What would you want for output?


When I look at these input records, I see the following mismatched records:

Key 0 - in file1 and file2, so write file2 record to output YES
Key 2 - only in file1 - write it to output or not? NO
Key 4 - in file1 and file2, so write file2 record to output YES
Key 6 - only in file2 - write it to output or not? YES
Key 7 - only in file1 - write it to output or not? NO

your patient is like the pope.....
thank you a lot I'll make you a present!!!!!!!!!....
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Mar 14, 2006 11:01 pm
Reply with quote

Ok, based on what you said in your last post, the following DFSORT/ICETOOL job should do what you asked for:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN1 DD DSN=...  input file1 (FB/330)
//IN2 DD DSN=...  input file2 (FB/330)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD DSN=...  output file (FB/330)
//TOOLIN DD *
* IN1->T1:  Copy records and add '1'.
COPY FROM(IN1) TO(T1) USING(CTL1)
* IN2->T1:  Copy records and add '2'.
COPY FROM(IN2) TO(T1) USING(CTL2)
* T1->OUT:  SELECT records that are not the same anywhere
* in 1-330 (do not match).  This eliminates the records that are
* the same in IN1 and IN2.  The remaining records are either
* records that are different in file1 and file2, or only appear in
* file1 or file2.  A '2' indicates the records from file2, so keep
* only those.
SELECT FROM(T1) TO(OUT) ON(1,330,BI) NODUPS USING(CTL3)
/*
//CTL1CNTL DD *
  OUTREC FIELDS=(1,330,331:C'1')
/*
//CTL2CNTL DD *
  OUTREC FIELDS=(1,330,331:C'2')
/*
//CTL3CNTL DD *
  OUTFIL FNAMES=OUT,INCLUDE=(331,1,CH,EQ,C'2'),
    OUTREC=(1,330)
/*


With the input shown in my previous post, OUT will have:

000000000SIMON1
000000004ANDRES
000000006CHARLIE
Back to top
View user's profile Send private message
miosne
Warnings : 1

New User


Joined: 13 Mar 2006
Posts: 63
Location: italy

PostPosted: Tue Mar 14, 2006 11:33 pm
Reply with quote

you have make a miracle!!! but I've also another question, if possible, can you explain me the meaning of the parameters that you have inserted in the sort card????
Back to top
View user's profile Send private message
miosne
Warnings : 1

New User


Joined: 13 Mar 2006
Posts: 63
Location: italy

PostPosted: Tue Mar 14, 2006 11:44 pm
Reply with quote

T1 DD DSN=&&ENFTR03,UNIT=SYSDA,
SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
why in this parameter the jcl response is :
JSORTA11 STEP1 OUT - DATA SET NOT FOUND
JSORTA11 STEP1 - STEP WAS NOT EXECUTED

why why why?!?! I know I'm a ASINO.... translate it from italian....
[/img]
Back to top
View user's profile Send private message
miosne
Warnings : 1

New User


Joined: 13 Mar 2006
Posts: 63
Location: italy

PostPosted: Tue Mar 14, 2006 11:46 pm
Reply with quote

.......... and nothing more....
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Mar 15, 2006 12:35 am
Reply with quote

Quote:
T1 DD DSN=&&ENFTR03,UNIT=SYSDA,
SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
why in this parameter the jcl response is :
JSORTA11 STEP1 OUT - DATA SET NOT FOUND
JSORTA11 STEP1 - STEP WAS NOT EXECUTED


The message says that the data set referenced by the OUT DD statement is missing. I don't know what you put in for //OUT DD, but you need to check it to make sure it's either new, or an existing data set if old. I'd have to see your actual JCL to help you more.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Mar 15, 2006 12:42 am
Reply with quote

Quote:
if possible, can you explain me the meaning of the parameters that you have inserted in the sort card????


I went back and added comments to my job to explain what I'm doing.

You can look up all of the parameters in "z/OS DFSORT Application Programming Guide", but instead I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

Use [URL] BBCode for External Links
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
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 Merge two VSAM KSDS files into third ... JCL & VSAM 6
Search our Forums:

Back to Top