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 

Compare two files and merge data to one file

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


Joined: 10 Sep 2004
Posts: 384
Topics: 79

PostPosted: Tue Jan 04, 2011 7:54 am    Post subject: Compare two files and merge data to one file Reply with quote

I have two files FileA and FileB. FileA and FileB have accounts(unique record key) 1-13 position.
File B has the packed decimal 4 bytes(15-18 positions) which should be inserted(overwrite) in fileA(27-30 position) for matching accounts.
I appreciate any help.

Code:

File A
----+----1----+----2----+----3----
8702381135801      H    CB    23 
8705322621992      H    CB    23 
8705233931804      H    CB    21     


Code:

File B
----+----1----+----
8702381135801 1234       
8705322621992 2225
1111111111232 4445
8705233931804 5555


Output: File A with data in position 27-30 position which is copied from File B for the matching accounts(1-13 position).

Code:

----+----1----+----2----+----3----
8702381135801      H1234CB    23 
8705322621992      H2225CB    23 
8705233931804      H5555CB    21     
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Jan 04, 2011 11:30 am    Post subject: Reply with quote

vak255,

Your description does not match the output. You mention that you need to replace the contents in pos 27-30 but your sample output shows that you actually overlaid the contents in pos 21-25.

The following DFSORT JCL will give you the desired results. I assumed that you want to overlay the contents in pos 27-30 and both files are of LRECL 80 and RECFM FB and you only need the match records.

Code:

//STEP0200 EXEC PGM=SORT             
//SYSOUT   DD SYSOUT=*               
//INA      DD DSN=Your input fileA,DISP=SHR     
//INB      DD DSN=Your input fileB,DISP=SHR     
//SORTOUT  DD SYSOUT=*               
//SYSIN    DD *                       
  OPTION COPY                         
  JOINKEYS F1=INA,FIELDS=(1,13,A)     
  JOINKEYS F2=INB,FIELDS=(1,13,A)     
  JOIN UNPAIRED                       
  REFORMAT FIELDS=(?,F1:1,80,F2:15,4)
  OUTFIL INCLUDE=(1,1,CH,EQ,C'B'),   
  BUILD=(2,26,82,4,32,50)             
//*

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vak255
Intermediate


Joined: 10 Sep 2004
Posts: 384
Topics: 79

PostPosted: Tue Jan 04, 2011 12:57 pm    Post subject: Reply with quote

Thanks Kolusu. I actually mean 27-30. I apologize for the confusion.
Back to top
View user's profile Send private message
vak255
Intermediate


Joined: 10 Sep 2004
Posts: 384
Topics: 79

PostPosted: Wed Jan 05, 2011 6:57 am    Post subject: Reply with quote

I got few syntax errors and I have corrected it but now I am getting U0016 abend with the below message.

Code:

JOINKEYS REFORMAT RECORD LENGTH=   84, TYPE = F 
SORTOUT  OUTREC FIELD OUTSIDE RANGE             
SYNCSMF  CALLED BY SYNCSORT; RC=0000       


Code:


//STEP0200 EXEC PGM=SORT                     
//SYSOUT   DD SYSOUT=*                       
//SORTJNF1 DD DSN= FILEA,DISP=SHR
//SORTJNF2 DD DSN= FILEB,DISP=SHR
//SORTOUT  DD DSN= OUT1,DISP=OLD
//SYSIN    DD *                             
  OPTION COPY                               
  JOINKEYS FILES=F1,FIELDS=(1,13,A)         
  JOINKEYS FILES=F2,FIELDS=(1,13,A)         
  JOIN UNPAIRED                             
  REFORMAT FIELDS=(F1:1,80,F2:15,4)         
  OUTFIL INCLUDE=(1,1,CH,EQ,C'B'),           
  BUILD=(2,26,82,4,32,50)                   
/*                   
Back to top
View user's profile Send private message
vak255
Intermediate


Joined: 10 Sep 2004
Posts: 384
Topics: 79

PostPosted: Wed Jan 05, 2011 7:16 am    Post subject: Reply with quote

//SORTJNF1 DD DSN= FILEA,DISP=SHR
//SORTJNF2 DD DSN= FILEB,DISP=SHR
//SORTOUT DD DSN= OUT1,DISP=OLD


All files are FB, LRECL=80
Back to top
View user's profile Send private message
vak255
Intermediate


Joined: 10 Sep 2004
Posts: 384
Topics: 79

PostPosted: Wed Jan 05, 2011 9:30 am    Post subject: Reply with quote

Here BUILD=(2,26,82,4,32,50)
82 is outside the range so its abending. I am checking.
Back to top
View user's profile Send private message
Brian Wood
Beginner


Joined: 14 Jan 2009
Posts: 37
Topics: 0
Location: USA

PostPosted: Wed Jan 05, 2011 10:39 am    Post subject: Reply with quote

Yak255:

The WER230A SORTOUT OUTREC FIELD OUTSIDE RANGE is issued because your REFORMAT statement is building a 84-byte record (80 bytes from F1 plus 4 bytes from F2), but your BUILD statement references a field that starts in position 82 for a length of 4 - this would be outside the range of your data.

I will review your earlier posting entries to see if we can help with a coding solution.
_________________
Brian Wood
SyncSort Mainframe Product Services
201-930-8260
zos_tech@syncsort.com
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


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

PostPosted: Wed Jan 05, 2011 11:15 am    Post subject: Reply with quote

vak255 wrote:
I got few syntax errors and I have corrected it but now I am getting U0016 abend with the below message.


Vak255,

My original job works fine with DFSORT. The messages indicates you are using SYNCSORT. I'm a DFSORT developer. DFSORT and Syncsort are competitive products. I'm happy to answer questions on DFSORT and DFSORT's ICETOOL, but I don't answer questions on Syncsort.
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Brian Wood
Beginner


Joined: 14 Jan 2009
Posts: 37
Topics: 0
Location: USA

PostPosted: Wed Jan 05, 2011 3:22 pm    Post subject: Reply with quote

vak255:

Please try this:

Code:
//STEP  EXEC  PGM=SORT
//SORTOUT  DD SYSOUT=*
//SORTJNF1 DD your.input.fileA
//SORTJNF2 DD your.input.fileB
//SORTOUT  DD  SYSOUT=*
//SYSIN  DD  *
 JOINKEYS FILE=F1,FIELDS=(1,13,A)
 JOINKEYS FILE=F2,FIELDS=(1,13,A)
 REFORMAT FIELDS=(F1:01,13,F1:14,07,F2:15,04,F1:25,56)
 SORT FIELDS=COPY


Please let me know if you require additional assistance.
_________________
Brian Wood
SyncSort Mainframe Product Services
201-930-8260
zos_tech@syncsort.com
Back to top
View user's profile Send private message Send e-mail
vak255
Intermediate


Joined: 10 Sep 2004
Posts: 384
Topics: 79

PostPosted: Wed Jan 05, 2011 11:20 pm    Post subject: Reply with quote

Thanks Kolusu and Brian for all the support. I will try this and will let you know.
Back to top
View user's profile Send private message
vak255
Intermediate


Joined: 10 Sep 2004
Posts: 384
Topics: 79

PostPosted: Thu Jan 06, 2011 1:51 am    Post subject: Reply with quote

It worked.

Kolusu and Brian, Thanks for your time.
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