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

How to tell if file changed using DFSORT


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

New User


Joined: 15 Dec 2005
Posts: 72
Location: RALEIGH NC, USA

PostPosted: Thu Apr 19, 2007 5:41 pm
Reply with quote

Hope you can help me icon_smile.gif

I have a file (FILE X) on DAY 1 that may have changed on DAY 2 (FILE Y).

I would like to write the records to FILE Z any records that have changed
from FILE Y to FILE Z

Code:

FILE X
------------
AAAABBBB
BBBBAAAA
BBBBDDDD
CCCCEEEE

FILE Y
------------
AAAABBBC
BBBBAAAA
BBBBDDDD
CCCCEEEX

OUTPUT FILE Z (I want to keep CHANGED RECORDS from File Y)
AAAABBBC
CCCCEEEX
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Thu Apr 19, 2007 5:52 pm
Reply with quote

In your example, are the first four characters the key? Or are the first seven characters? How would you know that the BBBBDDDD in file Y is not a changed BBBBAAAA in file X?
Back to top
View user's profile Send private message
srj1957

New User


Joined: 15 Dec 2005
Posts: 72
Location: RALEIGH NC, USA

PostPosted: Thu Apr 19, 2007 6:00 pm
Reply with quote

William Thompson wrote:
How would you know that the BBBBDDDD in file Y is not a changed BBBBAAAA in file X?


Thank you for replying so quickly and finding my error in example.
There isn't a key as such, The first 4 will stay constant, but bytes 5-8 could change

This is what I meant to submit

Code:

FILE X
------------
AAAABBBB
BBBBAAAA
CCCCDDDD
DDDDEEEE

FILE Y
------------
AAAABBBC
BBBBAAAA
CCCCDDDD
DDDDEEEX

OUTPUT FILE Z (I want to keep CHANGED RECORDS from File Y)
AAAABBBC
DDDDEEEX
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Thu Apr 19, 2007 6:27 pm
Reply with quote

Then the first four are unique keys, no duplicates, right?
for every unique key in file X will there be a matching key in file Y? Or could there be a key in X that was deleted from Y? Or a key in Y that was just added and not present in X?
Back to top
View user's profile Send private message
srj1957

New User


Joined: 15 Dec 2005
Posts: 72
Location: RALEIGH NC, USA

PostPosted: Thu Apr 19, 2007 6:31 pm
Reply with quote

William Thompson wrote:
Then the first four are unique keys, no duplicates, right?
for every unique key in file X will there be a matching key in file Y? Or could there be a key in X that was deleted from Y? Or a key in Y that was just added and not present in X?


William,
I appreciate your questions to clarify the data.

Unique Key and No Duplicates
Yes, for every unique key in file X will there be a matching key in file Y.
There will be only updates, - no additions or deletes
Back to top
View user's profile Send private message
srj1957

New User


Joined: 15 Dec 2005
Posts: 72
Location: RALEIGH NC, USA

PostPosted: Thu Apr 19, 2007 6:37 pm
Reply with quote

William Thompson wrote:
Or could there be a key in X that was deleted from Y? Or a key in Y that was just added and not present in X?


William,
What effect would there be if BOTH the above statements were to happen ?
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Thu Apr 19, 2007 6:54 pm
Reply with quote

srj1957 wrote:
Quote:
Or could there be a key in X that was deleted from Y? Or a key in Y that was just added and not present in X?
What effect would there be if BOTH the above statements were to happen ?
You are asking me?
You need to decide what you want on file Z in each case. In other words, is an unmatched key a "changed" record? Or only if it is on Y?
Are you still standing by
Quote:
Unique Key and No Duplicates
Yes, for every unique key in file X will there be a matching key in file Y.
There will be only updates, - no additions or deletes

lrecl and recfm?
Back to top
View user's profile Send private message
srj1957

New User


Joined: 15 Dec 2005
Posts: 72
Location: RALEIGH NC, USA

PostPosted: Thu Apr 19, 2007 7:06 pm
Reply with quote

You need to decide what you want on file Z in each case. In other words, is an unmatched key a "changed" record?

William,

Thanks your questions are excellent...

OK..lets say I want any unmatched key to be out put aswell as

Code:
FILE X
------------
AAAABBBB
BBBBAAAA
CCCCDDDD
DDDDEEEE


FILE Y
------------
AAAABBBC
BBBBAAAA
CCCCDDDD
DDDDEEEX
FFFFJJJJ

OUTPUT FILE Z (I want to keep CHANGED RECORDS and any unmatched from File Y)
-----------------------
AAAABBBC
DDDDEEEX
FFFFJJJJ

LRECL = 8
RECFM = FB
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Thu Apr 19, 2007 7:11 pm
Reply with quote

What would file Z look like if there was a"GGGG????" in file X but not in Y?
Back to top
View user's profile Send private message
srj1957

New User


Joined: 15 Dec 2005
Posts: 72
Location: RALEIGH NC, USA

PostPosted: Thu Apr 19, 2007 7:37 pm
Reply with quote

William Thompson wrote:
What would file Z look like if there was a"GGGG????" in file X but not in Y?


GGGG in file X could be ignored...
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: Thu Apr 19, 2007 8:56 pm
Reply with quote

srj1957,

Here's a DFSORT/ICETOOL job that will do what you asked for:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN1 DD DSN=...  input file1 (FB/8)
//IN2 DD DSN=...  input file2 (FB/8)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD DSN=...  output file (FB/8)
//TOOLIN   DD    *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT) ON(1,4,CH) KEEPNODUPS -
  WITH(9,4) WITH(17,1) USING(CTL3)
/*
//CTL1CNTL DD *
  INREC BUILD=(1,8,17:C'1')
/*
//CTL2CNTL DD *
  INREC BUILD=(1,4,9:5,4,17:C'2')
/*
//CTL3CNTL DD *
  OUTFIL FNAMES=OUT,
    INCLUDE=(17,1,CH,EQ,C'2',AND,
      5,4,BI,NE,9,4,BI),
    BUILD=(1,4,9,4)
/*
Back to top
View user's profile Send private message
srj1957

New User


Joined: 15 Dec 2005
Posts: 72
Location: RALEIGH NC, USA

PostPosted: Thu Apr 19, 2007 10:19 pm
Reply with quote

Thank you all so much for help... icon_biggrin.gif

Even though I read the DFSORT tricks and the other DFSORT links I find it hard to come up with a solution... icon_neutral.gif

Thanks again

Steve
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top