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
 

 

compare two files and replace record in file2

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
faizm

New User


Joined: 13 Apr 2012
Posts: 59
Location: India

PostPosted: Tue Sep 02, 2014 7:16 pm    Post subject: compare two files and replace record in file2
Reply with quote

Hi,
My reqmt is to compare two files of (same LRECL = 2048, and RECFM = FB) based on key and replace the full record in file 2 with that of full record of F1 if the key matches. I do not want to replace the record in file 2 if the key dont matches.
Here is an example:

F1 and F2 both are having same key: (3,3) and (9,2)

F1

Code:
AAAXXXBBE1AJAY...
MMMZZZBBE2BOB...


F2
Code:
111XXXDDE1ROHIT..
AAAXYZBBE2DONNA..
222ZZZMME2RAKESH..


Output should be
Code:
AAAXXXDDE1AJAY..
AAAXYZBBE2DONNA..
MMMZZZBBE2BOB..


Please help how we can get this using overlay in JOINKEYS. Thanks.

Code'd
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Wed Sep 03, 2014 4:39 am    Post subject: Reply to: compare two files and replace record in file2
Reply with quote

What have you tried and what problems are you having?
Back to top
View user's profile Send private message
faizm

New User


Joined: 13 Apr 2012
Posts: 59
Location: India

PostPosted: Wed Sep 03, 2014 11:02 am    Post subject: Reply to: compare two files and replace record in file2
Reply with quote

Hi Bill,
Thanks for the reply.
In actual the file length is 20476 and RECFM is VB for both input files and have to replace two fields in second file F2 with the values at same position in file 1- one field is of one char length at 531 and second field is packed decimal starts at 532 of length 6.

I am using the below sysin card but it throws the syntax error 'INREC STATEMENT : SYNTAX ERROR '

Code:
//SYSIN DD *                                           
  SORT FIELDS=COPY                                     
  JOINKEYS FILES=F1,FIELDS=(5,3,A,9,15,A,24,8,A,34,4,A)
  JOINKEYS FILES=F2,FIELDS=(5,3,A,9,15,A,24,8,A,34,4,A)
  REFORMAT FIELDS=(F2:1,20476,F1:532,6,?)               
  JOIN UNPAIRED,F2                                     
  INREC IFOUTLEN=20476,                                 
  IFTHEN=(WHEN=(20483,1,CH,EQ,C'B'),                   
  OVERLAY=(532:532,6)                                   
/*                                             


I was trying to replace only one of the field using the above card. what should be the syntax when we replace two fields.Can you pls guide here. Thanks

Code'd again
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Wed Sep 03, 2014 12:28 pm    Post subject: Reply to: compare two files and replace record in file2
Reply with quote

Please use the Code tags.

When you get an error message you are stuck with, you need to paset the sysout so we can see where the error pointer is.

However, you have a missing closing bracket.

Do you really want to make all your variable-length records the same size?

Code:
  SORT FIELDS=COPY                                     
  JOINKEYS FILES=F1,FIELDS=(5,3,A,9,15,A,24,8,A,34,4,A)
  JOINKEYS FILES=F2,FIELDS=(5,3,A,9,15,A,24,8,A,34,4,A)
  REFORMAT FIELDS=(F2:1,4,F1:531,7,?,F2:5)               
  JOIN UNPAIRED,F2                                     
  INREC IFTHEN=(WHEN=(12,1,CH,EQ,C'B'),                   
                     OVERLAY=(539:5,7))
  OUTREC BUILD=(1,4,13)


Something like that, untested. This may take some explaining, so take the manual, and try to work out what it is doing, including fixing anything. If you get stuck, post back, with the Code tags.
Back to top
View user's profile Send private message
faizm

New User


Joined: 13 Apr 2012
Posts: 59
Location: India

PostPosted: Wed Sep 03, 2014 5:00 pm    Post subject: Reply to: compare two files and replace record in file2
Reply with quote

Hi Bill,
I have tried running the job and the second file got updated with much more records than expected.
To test, I had only one record in file 1 and second file was having around 1000 records. Though the key is matching, could there be a possibility that due to VB file, it is somewhere updating the unnecessary records.
Also, can you pls give a quick hint on the below condition so that I can have idea what it says'
Code:
INREC IFTHEN=(WHEN=(12,1,CH,EQ,C'B'),
OVERLAY=(539:5,7))                   
OUTREC BUILD=(1,4,13)               


Thanks
Back to top
View user's profile Send private message
David Robinson

Active User


Joined: 21 Dec 2011
Posts: 175
Location: UK

PostPosted: Wed Sep 03, 2014 5:08 pm    Post subject:
Reply with quote

Which statement couldn't you find in the manual, or, if you found them all, which one did you not understand the explanation for?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Wed Sep 03, 2014 5:28 pm    Post subject: Reply to: compare two files and replace record in file2
Reply with quote

You need to understand the REFORMAT record.

It will be variable-length, so it needs an RDW (can come from either file). That's the 1,4 bit. Then you have three fixed-length pieces of information you want: two fields from F1, and the match-marker. The two fields are consecutive, feel free to code them as individual fields. The match-marker appears as the ? (you know that) and then we need the entire variable-length data from F2, which we code as "5", which means "from position five to the end of the current record".

Those fields on the REFORMAT record are all in sequential order, so now you should understand the positions of everything.

When you get to the BUILD remember what I've just said about the variable parts of records.
Back to top
View user's profile Send private message
faizm

New User


Joined: 13 Apr 2012
Posts: 59
Location: India

PostPosted: Wed Sep 03, 2014 7:39 pm    Post subject: Reply to: compare two files and replace record in file2
Reply with quote

Thanks Bill.
Now I have some confusion here - 1. why we are using '12' (starting position) in WHEN condition.
2. OVERLAY=(539:5,7) to which I think should be OVERLAY=(531:531,7) as we are replacing value at 531 in second file with value at 531 of length 7 in file 1.
Thanks
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Wed Sep 03, 2014 8:07 pm    Post subject: Reply to: compare two files and replace record in file2
Reply with quote

Because we've added eight bytes to the start of the record, in the REFORMAT statement. Read what I wrote again. Go through it with pencil and paper. See what happens from the creation of the REFORMAT record through to the creation of the output.
Back to top
View user's profile Send private message
faizm

New User


Joined: 13 Apr 2012
Posts: 59
Location: India

PostPosted: Thu Sep 04, 2014 12:23 pm    Post subject:
Reply with quote

Thanks Bill.
I am getting just one issue now:
the input file F1 field that needs to be moved into file 2 field has data type as PIC 9(9)V9(2).

In the input file (F1) the value is 25.00. However the value in the output file F2 is not coming at the exact position.

Code:
//SYSIN DD *                                             
  SORT FIELDS=COPY                                       
  JOINKEYS FILES=F1,FIELDS=(9,3,A,13,15,A,28,8,A,38,4,A) 
  JOINKEYS FILES=F2,FIELDS=(9,3,A,13,15,A,28,8,A,38,4,A) 
  REFORMAT FIELDS=(F2:1,4,F1:534,1,F1:535,6,?,F2:5)       
  JOIN UNPAIRED,F2                                       
  INREC IFTHEN=(WHEN=(12,1,CH,EQ,C'B'),                   
  OVERLAY=(534:5,1,535:6,6))                             
  OUTREC BUILD=(1,4,13)                                   
/*                                                       


Thanks
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
This topic is locked: you cannot edit posts or make replies. How to use 2 input files in control c... Gunapala CN DFSORT/ICETOOL 23 Thu Oct 13, 2016 3:42 pm
No new posts Replace repeated JCL with looping REXX prino CLIST & REXX 3 Thu Oct 13, 2016 5:30 am


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