|
View previous topic :: View next topic
|
| Author |
Message |
faizm
New User
Joined: 13 Apr 2012 Posts: 59 Location: India
|
|
|
|
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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| What have you tried and what problems are you having? |
|
| Back to top |
|
 |
faizm
New User
Joined: 13 Apr 2012 Posts: 59 Location: India
|
|
|
|
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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
faizm
New User
Joined: 13 Apr 2012 Posts: 59 Location: India
|
|
|
|
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 |
|
 |
David Robinson
Active User
Joined: 21 Dec 2011 Posts: 199 Location: UK
|
|
|
|
| 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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
faizm
New User
Joined: 13 Apr 2012 Posts: 59 Location: India
|
|
|
|
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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| 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 |
|
 |
faizm
New User
Joined: 13 Apr 2012 Posts: 59 Location: India
|
|
|
|
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 |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|