Posted: Fri Mar 22, 2024 8:37 am Post subject: Replace variable in File 2 using File 1
Hi Team,
I have a requirement where we have two input files having field1 of 19 bytes and field2 of 19 bytes again. Another file(File2) having some data.
For all the records starting with '05' in File2, we want to replace the records starting from position 10 with first field of File1 and if records starting from position 40 is not spaces than replace with second field of File1.
Note: We do not have any specific data at these positions.
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Fri Mar 22, 2024 1:18 pm Post subject:
Srishti Rawat wrote:
For all the records starting with '05' in File2, we want to replace the records starting from position 10 with first field of File1 and if records starting from position 40 is not spaces than replace with second field of File1.
Srishti Rawat,
How do you map 05 records in file 2 with file 1? ie Type 05 record1 in file 2 should be matched with record 1 in file 1? record 2 should be matched with record 2 and so on ?
First '05' record of File2 should be mapped with first record of File1. Rest all the records(other than'05') should be written as it is(in the same order) in the output file. Then next '05' record should be mapped with second record of File1 and so on.
File1 record length: 80 bytes
File2 record length: 1224 bytes
Output file should be of record length 1224 bytes.
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Fri Mar 22, 2024 6:54 pm Post subject:
Srishti Rawat,
You need to pay attention to the questions asked and ensure you answered all of them
I asked you this
Kolusu wrote:
what are the DCB properties of file 1 and file 2?
You answered with just LRECL but nothing about the RECFM. So I assumed that your both files have RECFM=FB . If your input files are VB then you are on your own to modify the below code.
Use this untested JCL which will give you the desired results.
Condition:
Replace the records starting from position 10 with first field of File1 and if records starting from position 40 is not spaces than replace with second field of File1.
But this is not working for the condition: 'if records starting from position 40 is not spaces than replace with second field of File1.' Right now this is replacing all the '05' records with second field of File1.
I tried adding below additional condition to differentiate for record starting with '05' and position 40 having spaces:
First Step: Replacing the 10th position with first field.
Second step using the output of first step and checking for the spaces in the position 40, if not spaces than replace.
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Thu Mar 28, 2024 9:46 am Post subject:
Srishti Rawat wrote:
Hi Kolusu,
Thank you for the solution.
Condition:
Replace the records starting from position 10 with first field of File1 and if records starting from position 40 is not spaces than replace with second field of File1.
But this is not working for the condition: 'if records starting from position 40 is not spaces than replace with second field of File1.' Right now this is replacing all the '05' records with second field of File1.
Really ? if you copied the code as is then it you wouldn't have this problem.
Look at the 2nd record in your input file
Quote:
05HITHIS 0106876328788378798KJKJaaa
and since the field at 40 is SPACES, we did not replace it.
Quote:
05HITHIS 1234567891000022002KJKJaaa
I can prove that to you quite easily. Run this job as is
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Wed Apr 03, 2024 12:01 pm Post subject:
Srishti Rawat wrote:
Hi Kolusu,
I made some changes in the positions that's why it wasn't working for me. This code is working.
Srishti Rawat,
You should have mentioned that, instead of implying that the proposed solution does NOT work. we cannot look over your shoulder and see what the real problem unless you explain it clearly.
Now the question is why did you quote incorrect positions? or you just had to adjust the positions because you failed to explain that one of your file is VB file?
Btw if the input LRECL 1224 is a VB dataset then the above control cards would literally make a FB file as every record is made to a length of 1224.
You need to pay attention to the questions asked and answer all of them, so that you get the optimal solution. _________________ Kolusu
www.linkedin.com/in/kolusu
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