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 

SORT 2 FILES - OUTPUTING THE DIFFERENCES FROM BOTH INPUTS.

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
prog_mario
Beginner


Joined: 08 Sep 2007
Posts: 86
Topics: 27

PostPosted: Tue Jun 26, 2012 1:32 pm    Post subject: SORT 2 FILES - OUTPUTING THE DIFFERENCES FROM BOTH INPUTS. Reply with quote

Hi everybody. I'm trying this since this morning...
I have 2 files, length 106 bytes.
1st is an old table unload.
2nd is the current table unload.
I need to compare both files and if anything is different I need to write a record using the old information and the new one, so the person will be able to check what was changed.
I would have a 212 bytes long output file.
I was trying this;
Code:

 JOINKEYS FILE=F1,FIELDS=(1,106,A)                         
  JOINKEYS FILE=F2,FIELDS=(1,106,A)                         
  JOIN UNPAIRED,ONLY,F2                                     
  REFORMAT FIELDS=(F1:001,005,                   LOCN OLD            001-005
                   F2:001,005,                   LOCN NEW            006-005
                   F1:006,011,                   NDC-UPC-NBR OLD     011-011
                   F2:006,011,                   NDC-UPC-NBR NEW     022-011
                   F1:017,010,                   EFF-DTE OLD         033-010
                   F2:017,010,                   EFF-DTE NEW         043-010
                   F1:027,010,                   EXP-DTE OLD         052-010
                   F2:027,010,                   EXP-DTE NEW         063-010
                   F1:037,030,                   DESC OLD            073-030
                   F2:037,030,                   DESC NEW            103-030
                   F1:067,003,                   PERCENT OLD         133-003
                   F2:067,003,                   PERCENT NEW         136-003
                   F1:070,003,                   MIN-QTY OLD         139-003
                   F2:070,003,                   MIN-QTY NEW         142-003
                   F1:073,026,                   LST-MNT-TSMP OLD    145-026
                   F2:073,026,                   LST-MNT-TSMP NEW    171-026
                   F1:099,008,                   LST-OPR-ID OLD      197-008
                   F2:099,008)                   LST-OPR-ID NEW      205-008
 SORT FIELDS=COPY                           

Any help please?
_________________
The more I learn, the more I want to learn.
Back to top
View user's profile Send private message
prog_mario
Beginner


Joined: 08 Sep 2007
Posts: 86
Topics: 27

PostPosted: Tue Jun 26, 2012 2:45 pm    Post subject: Reply with quote

EXAMPLE:
FILE1:
Code:

PEDRO2012-06-26MANAGER

FILE2:
Code:

PEDRO2012-06-26PRESIDENT

THE OUTPUT I NEED WOULD BE:
Code:

PEDRO     2012-06-26          MANAGERPREDISENT

PEDRO CONTINUES THE SAME, SO, WE HAVE 5 SPACES AFTER IT.
2012-06-26 CONTINUES THE SAME, SO, WE HAVE 10 SPACES AFTER IT.
MANAGER WAS CHANGED TO PRESIDENT, SO, WE HAVE THE OLD INFORMATION AND THE NEW INFORMATION EIGHT AFTER IT.
_________________
The more I learn, the more I want to learn.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Tue Jun 26, 2012 4:25 pm    Post subject: Reply with quote

prog_mario,

Your are comparing entire record and then want to do a field by field comparison which makes it tough. There are ways to do but you would need DFSORT for that and you are running syncsort which does not support the features DFSORT has.

Kolusu

PS: use post using CODE tags . Check this link which explains the usage of code tags

http://www.mvsforums.com/helpboards/viewtopic.php?p=19031#19031
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
papadi
Supermod


Joined: 20 Oct 2009
Posts: 594
Topics: 1

PostPosted: Tue Jun 26, 2012 4:39 pm    Post subject: Reply with quote

When there is some mis-match, i suspect the records will not "join" as you have chosen the entire record length as the "join key".

What if the change was that PEDRO was changed to MARIA in that row in the database? The unloaded values would not be syncronized Confused

I believe your challange is more of the logistics of the task rather than the sort product used. . .

Possibly, i misunderstand.
_________________
All the best,

di
Back to top
View user's profile Send private message
William Collins
Supermod


Joined: 03 Jun 2012
Posts: 437
Topics: 0

PostPosted: Wed Jun 27, 2012 3:24 am    Post subject: Reply with quote

Key is entire record, then you want differences at field level?

So you have no key, and no way to know what to attempt to match to what.

Without an explicit or implicit key, you are stuck.

Is there a one-to-one relationship between the files?
Back to top
View user's profile Send private message
papadi
Supermod


Joined: 20 Oct 2009
Posts: 594
Topics: 1

PostPosted: Wed Jun 27, 2012 10:06 am    Post subject: Reply with quote

Hello,

If the files are guaranteed to be 1-for-1, you could append a sequence number to both files, join on the sequence number and compare whatever you'd like to compare.

This falls apart if the files have add/deleted information in additon to changed values. . .
_________________
All the best,

di
Back to top
View user's profile Send private message
prog_mario
Beginner


Joined: 08 Sep 2007
Posts: 86
Topics: 27

PostPosted: Sat Jun 30, 2012 7:08 am    Post subject: Reply with quote

Hi everybody I'm really glad receiving all that attention from all of you.
Talking with my business partner, he said that only 2 fields could be modified.
One thing I forgot to say (Kolusu) is that we have both dfsort and syncsort.
So I solved the problem this way:
Code:

********************************* Top of Data ***************
  JOINKEYS FILE=F1,FIELDS=(1,36,A)   file 1 key                           
  JOINKEYS FILE=F2,FIELDS=(1,36,A)   file 2 key                           
  REFORMAT FIELDS=(F1:001,005,      LOCN OLD         001-005
                   F1:006,011,      NDC-UPC-NBR OLD  006-011
                   F1:017,010,      EFF-DTE OLD      017-010
                   F1:027,010,      EXP-DTE OLD      027-010
                   F1:037,030,      DESC OLD         037-030
                   F1:067,003,      PERCENT OLD      067-003
                   F1:070,003,      MIN-QTY OLD      070-003
                   F2:073,026,      LST-MNT-TSMP NEW 073-026
                   F2:099,008,      LST-OPR-ID NEW   099-008
                   F2:067,003,      PERCENT NEW      107-003
                   F2:070,003)      MIN-QTY NEW      110-003
  INCLUDE COND=(067,003,PD,NE,107,003,PD,OR,                 
                070,003,PD,NE,110,003,PD)                   
  SORT FIELDS=COPY       
                                   
******************************** Bottom of Data *************

Thanks a lot guys, once again, for the attention.
_________________
The more I learn, the more I want to learn.
Back to top
View user's profile Send private message
papadi
Supermod


Joined: 20 Oct 2009
Posts: 594
Topics: 1

PostPosted: Sat Jun 30, 2012 2:52 pm    Post subject: Reply with quote

You're welcome - good to hear it is working Smile

Thank you for posting your soluton.

If we had understood that the first part of the records is the "key" from the beginning, the answer would hav been found much sooner Wink
_________________
All the best,

di
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
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