Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Sort for conditional merge of two files

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
hemu88

New User


Joined: 13 May 2011
Posts: 29
Location: India

PostPosted: Wed Sep 21, 2011 12:11 pm    Post subject: Sort for conditional merge of two files
Reply with quote

Hi All,

I have 2 files: File A and File B as below. Field 1 is the key. I am trying to write a sort as below:

1. Record present in File A, not in File B - Need to write to output
2. Record present in File B, not in File A - Need to write to output
3. Record present in File A as well as File B - then writing to output depends on field 3 as below:
i) Field 3 is same - Write File B record.
ii) Field 3 is different - Do not write both.

File A:
123 rohan mumbai
234 sanu chennai
456 aaaa delhi

File B:
123 d23 chennai
345 d45 mumbai
456 d67 delhi

Output:
234 sanu chennai
345 d45 mumbai
456 d67 delhi

I tried doing this by excluding matching records. but I am not getting how to check for field 3 condition. Can someone pls help me with this sort?
Back to top
View user's profile Send private message

hemu88

New User


Joined: 13 May 2011
Posts: 29
Location: India

PostPosted: Wed Sep 21, 2011 1:47 pm    Post subject: Reply to: Sort for conditional merge of two files
Reply with quote

can you pls help me? let me know if requirement is unclear..
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6967
Location: porcelain throne

PostPosted: Wed Sep 21, 2011 2:11 pm    Post subject:
Reply with quote

well we looked at the control cards with which you have problems and see no issues.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Wed Sep 21, 2011 2:18 pm    Post subject:
Reply with quote

Please show us what you have so far. Are you using SyncSort? What are the record format and lrecls of your inputs and output?
Back to top
View user's profile Send private message
hemu88

New User


Joined: 13 May 2011
Posts: 29
Location: India

PostPosted: Wed Sep 21, 2011 2:56 pm    Post subject: Reply to: Sort for conditional merge of two files
Reply with quote

I am using below sort:

Code:

//STEP1   EXEC  PGM=SYNCSORT                                           
//SORTJNF1 DD DSN=FILEA                                                         
//SORTJNF2 DD DSN=FILEB                                                         
//SORTOUT  DD SYSOUT=*                                                 
//SYSPRINT DD SYSOUT=*                                                 
//SYSOUT   DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
JOINKEYS FILE=F2,FIELDS=(1,3,A)                                       
JOINKEYS FILE=F1,FIELDS=(1,3,A)                                       
JOIN UNPAIRED,F1,ONLY                                                 
REFORMAT FIELDS=(F1:1,80)                                             
SORT FIELDS=COPY                                                       
/*


this is giving only unmatched records of the first File A to output. I am not getting to check condition for my requirement.
Back to top
View user's profile Send private message
hemu88

New User


Joined: 13 May 2011
Posts: 29
Location: India

PostPosted: Wed Sep 21, 2011 2:57 pm    Post subject: Reply to: Sort for conditional merge of two files
Reply with quote

RECFM=FB & LRECL=80
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Wed Sep 21, 2011 4:10 pm    Post subject: Reply to: Sort for conditional merge of two files
Reply with quote

Quote:
JOIN UNPAIRED,F1,ONLY


This is an obvious explanation for why unpaired from first file only. Find where this is defined in your manual, and then find how to create the output you want from the stuff that is similar but gives you the correct output.

The "IF" bit I probably have to leave for the Sort Wizards...
Back to top
View user's profile Send private message
hemu88

New User


Joined: 13 May 2011
Posts: 29
Location: India

PostPosted: Fri Sep 23, 2011 11:03 am    Post subject: Reply to: Sort for conditional merge of two files
Reply with quote

Hi All,

I got soln for this. I am using two sort steps as below.
1. Unpaired from FileA and FileB
Code:

//SYSIN     DD *                                               
 JOINKEYS FILES=F1,FIELDS=(1,3,A)                             
 JOINKEYS FILES=F2,FIELDS=(1,3,A)                             
 JOIN UNPAIRED                                         
 REFORMAT FIELDS=(F1:1,80)                                     
 SORT FIELDS=COPY                                               
*/


2. Paired and Field3 matching
Code:

//SYSIN     DD *                                               
 JOINKEYS FILES=F1,FIELDS=(1,3,A,10,6,A)                       
 JOINKEYS FILES=F2,FIELDS=(1,3,A,10,6,A)                       
 REFORMAT FIELDS=(F2:1,80)                                     
 SORT FIELDS=COPY                                               
*/


then cobining both will give my reuired o/p..
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to change 'K' or 'M' use Sort vice_versa DFSORT/ICETOOL 5 Thu May 18, 2017 7:11 am
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
No new posts Unable to create multiple files using... mbattu COBOL Programming 3 Fri May 05, 2017 5:35 pm
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
This topic is locked: you cannot edit posts or make replies. SORT trick needed bshkris SYNCSORT 6 Tue May 02, 2017 4:35 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us