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 

Unpaired Records from File2 using Syncsort

 
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: Wed Dec 08, 2010 1:24 pm    Post subject: Unpaired Records from File2 using Syncsort Reply with quote

Hi everyone, I have a join step which must process only the paired keys, then I need to check the other values for changes. If any other value has changed I need to write the output from my F2 file. If I have no changes I need to ignore the record.
My data:
F1:01,05,CH,
F1:06,05,CH,
F1:11,05,CH,
F1:16,05,CH.

F2 has the same layout.

Any help?
Thanks a lot.
Back to top
View user's profile Send private message
papadi
Supermod


Joined: 20 Oct 2009
Posts: 594
Topics: 1

PostPosted: Wed Dec 08, 2010 2:15 pm    Post subject: Reply with quote

Post some sample data from both input files and the output you want from that sample input. If either/both file(s) may contain duplicates, show this in the sample data.

Explain any processing rules.

Why not just use 1,20 instead of 4 fields. . . Confused
_________________
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: Wed Dec 08, 2010 3:34 pm    Post subject: Reply with quote

Right,

FILE_OLD
111110000000000
222220000000000

FILE_NEW
111110000011111
222220000000000

OUTPUT SHOULD BE:
111110000011111

I need to join both old and new files paired on the first 5 bytes.
Then I need to analyze the paired record and check if the remaining bytes are equal.
If they are equal I need to ignore the paired record and analyze the next one.
But if the remaining bytes are not equal I need to write the output file from FILE_NEW.
Back to top
View user's profile Send private message
prog_mario
Beginner


Joined: 08 Sep 2007
Posts: 86
Topics: 27

PostPosted: Wed Dec 08, 2010 3:35 pm    Post subject: Reply with quote

One more thing, the input files don't have duplicates.
_________________
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: Wed Dec 08, 2010 3:38 pm    Post subject: Reply with quote

Well, if my input don't have duplicates, don't you think that if I look for the unpaired from FILE_NEW could solve the problem?
_________________
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: Wed Dec 08, 2010 4:19 pm    Post subject: Reply with quote

Yes, it works.
I just need to use
JOIN UNPAIRED,F2,ONLY
comparing the entire records to each other.

Thanks anyway, everybody!!!
_________________
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: Wed Dec 08, 2010 4:35 pm    Post subject: Reply with quote

Congrats on getting it working - thank you for the updates Smile

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


Joined: 08 Sep 2007
Posts: 86
Topics: 27

PostPosted: Mon Dec 13, 2010 2:05 pm    Post subject: Reply with quote

No, a new information changed everything.

FILE_OLD
Code:

111110000000000AAAAABBBBB
111110000000000CCCCCDDDDD
111110000000000DDDDDEEEEE
222220000000000AAAAABBBBB
222220000000000CCCCCDDDDD
222220000000000HHHHHTTTTT

FILE_NEW
Code:

111110000011111


OUTPUT SHOULD BE:
Code:

111110000011111AAAAABBBBB
111110000011111CCCCCDDDDD
111110000011111DDDDDEEEEE
222220000000000AAAAABBBBB
222220000000000CCCCCDDDDD
222220000000000HHHHHTTTTT


FILE_OLD contains duplicates but FILE_NEW doesn't.
The keys are the first 5 bytes from each file.
If I have matching keys I need to update the record from FILE_OLD(6,10) using the data from FILE_NEW(6,10) and write it to the output.
I need to do that with every matching record from FILE_OLD.
So, my output will have the same records from FILE_OLD but with positions 6,10 updated from FILE_NEW when matching keys.
Back to top
View user's profile Send private message
prog_mario
Beginner


Joined: 08 Sep 2007
Posts: 86
Topics: 27

PostPosted: Mon Dec 13, 2010 4:10 pm    Post subject: Reply with quote

Correction:
Positions that are being updated are (11,5).
_________________
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 Dec 14, 2010 8:46 am    Post subject: Reply with quote

Finally:
Code:

  JOINKEYS FILE=F1,FIELDS=(1,05,A)     OLD FILE       
  JOINKEYS FILE=F2,FIELDS=(1,05,A)     UPDATES
  JOIN UNPAIRED,F1                              F1 MATCHED AND UNMATCHED           
  REFORMAT FIELDS=(F1:01,95,             OLD FILE                 
                   F2:01,20)                          NEW FILE     
  OUTREC IFOUTLEN=95,                       OUT FILE LENGTH               
         IFTHEN=(WHEN=(01,5,CH,EQ,96,5,CH),     TEST EQUALS           
         BUILD=(001,020,                         FROM F1
                101,015,                              FROM F2   
                036,060))                             FROM F1   
  SORT FIELDS=(01,05,CH,A,                           
               06,05,CH,A,                           
               11,10,CH,A)

_________________
The more I learn, the more I want to learn.
Back to top
View user's profile Send private message
Dibakar
Advanced


Joined: 02 Dec 2002
Posts: 700
Topics: 63
Location: USA

PostPosted: Tue Dec 14, 2010 2:05 pm    Post subject: Reply with quote

prog_mario,

thanks for sharing the solution.
_________________
Regards,
Diba
Back to top
View user's profile Send private message Send e-mail
mf_user
Intermediate


Joined: 01 Jun 2003
Posts: 372
Topics: 105

PostPosted: Fri Dec 17, 2010 6:19 am    Post subject: Reply with quote

I ran your solution but got below error bonk

Code:

WER230A  REFORMAT FIELD OUTSIDE RANGE 

_________________
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
mf_user
Intermediate


Joined: 01 Jun 2003
Posts: 372
Topics: 105

PostPosted: Fri Dec 17, 2010 6:57 am    Post subject: Reply with quote

Ok....after several trial and error attempts this is how I could achieve what prog_mario shown in output:

Code:

//STEP0001 EXEC PGM=SORT   
//SYSOUT   DD SYSOUT=*     
//SORTOUT  DD SYSOUT=*     
//SORTJNF1 DD *           
111110000000000AAAAABBBBB 
111110000000000CCCCCDDDDD 
111110000000000DDDDDEEEEE 
222220000000000AAAAABBBBB 
222220000000000CCCCCDDDDD 
222220000000000HHHHHTTTTT 
//SORTJNF2 DD *           
111110000011111           
//SYSIN    DD *                                                     
  JOINKEYS FILE=F1,FIELDS=(1,05,A)          OLD FILE               
  JOINKEYS FILE=F2,FIELDS=(1,05,A)          UPDATES                 
  JOIN UNPAIRED,F1                          F1 MATCHED AND UNMATCHED
  REFORMAT FIELDS=(F1:01,80,                OLD FILE               
                   F2:01,20)                NEW FILE               
  SORT FIELDS=COPY                                                 
  OUTREC IFOUTLEN=95,                       OUT FILE LENGTH         
         IFTHEN=(WHEN=(01,5,CH,EQ,81,5,CH), TEST EQUALS             
         BUILD=(001,005,                    FROM F1                 
                086,010,                    FROM F2                 
                016,010))                   FROM F1                 


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
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