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 

Replace variable in File 2 using File 1

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


Joined: 03 Nov 2021
Posts: 20
Topics: 6

PostPosted: Fri Mar 22, 2024 8:37 am    Post subject: Replace variable in File 2 using File 1 Reply with quote

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.

File1:
Quote:

1234567891000022000 2344554444439990002
1234567891000022002 2344554444439990402
1234567891000022005 2344554444439990023
.
.


File2:
Quote:

00hkhkjlk
01jjkhlkjl
05HITHIS 0106876328762378798KJKJKJ;LK;L2344554444439990002
02klkjflj
05HITHIS 0106876328788378798KJKJaaa
05HITHIS 0106876328788378798KJKJKJ;LK;L2344554444439990333
09njkjlkj
.
.


Expected Output:
Quote:

00hkhkjlk
01jjkhlkjl
05HITHIS 1234567891000022000KJKJKJ;LK;L2344554444439990002
02klkjflj
05HITHIS 1234567891000022002KJKJaaa
05HITHIS 1234567891000022005KJKJKJ;LK;L2344554444439990023
09njkjlkj
.
.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Fri Mar 22, 2024 1:18 pm    Post subject: Reply with quote

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 ?

what are the DCB properties of file 1 and file 2?

Ie you say
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Srishti Rawat
Beginner


Joined: 03 Nov 2021
Posts: 20
Topics: 6

PostPosted: Fri Mar 22, 2024 2:06 pm    Post subject: Reply with quote

Hi Kolusu,

Thats right.

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.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Fri Mar 22, 2024 6:54 pm    Post subject: Reply with quote

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.

Code:

//STEP0100 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//INA      DD DISP=SHR,DSN=Your.Input.FB.LRECL.1224.dataset
//INB      DD DISP=SHR,DSN=Your.Input.FB.LRECL.0080.dataset
//SORTOUT  DD DSN=Your.output.file,
//            DISP=(NEW,CATLG,DELETE),
//            SPACE=(CYL,(X,Y),RLSE)
//SYSIN    DD *                                               
  JOINKEYS F1=INA,FIELDS=(1235,8,A)                           
  JOINKEYS F2=INB,FIELDS=(0001,8,A),SORTED,NOSEQCK
  JOIN UNPAIRED,F1                                           
  REFORMAT FIELDS=(F1:0001,1234,                             
                      ?,                                     
                   F2:09,40)                                 
                                                             
  INREC IFOUTLEN=1234,                                       
          IFTHEN=(WHEN=(1235,01,CH,EQ,C'B'),                 
               OVERLAY=(10:1237,19,                           
                        40:40,19,CHANGE=(19,C' ',C' '),       
                                NOMATCH=(1257,19)))           
  SORT FIELDS=(1225,8,CH,A)                               
  OUTREC BUILD=(01,1224)
                                                           
/*                                                           
//JNF1CNTL DD *                                               
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(1225:SEQNUM,8,ZD)),       
        IFTHEN=(WHEN=(01,02,CH,EQ,C'05'),                     
             OVERLAY=(1235:SEQNUM,8,ZD))                     
/*                                                           
//JNF2CNTL DD *                                               
  INREC BUILD=(SEQNUM,8,ZD,X,01,40)                           
/*                                                           

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


Joined: 03 Nov 2021
Posts: 20
Topics: 6

PostPosted: Thu Mar 28, 2024 5:10 am    Post subject: Reply with quote

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.

I tried adding below additional condition to differentiate for record starting with '05' and position 40 having spaces:
Code:

//JNF1CNTL DD *                                               
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(1225:SEQNUM,8,ZD)),       
        IFTHEN=(WHEN=(01,02,CH,EQ,C'05'),                     
             OVERLAY=(1235:SEQNUM,8,ZD))   
        IFTHEN=(WHEN=(01,02,CH,EQ,C'05',AND,40,19,CH,EQ,C' '),               
             OVERLAY=(1245:SEQNUM,8,ZD))   


But still not getting a differentiating character for this condition while trying to join. Can you please help to handle this condition.
Back to top
View user's profile Send private message
Srishti Rawat
Beginner


Joined: 03 Nov 2021
Posts: 20
Topics: 6

PostPosted: Thu Mar 28, 2024 5:33 am    Post subject: Reply with quote

I am able to do it in two steps.

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.
Code:

//JNF1CNTL DD *                                               
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(1225:SEQNUM,8,ZD)),       
        IFTHEN=(WHEN=(01,02,CH,EQ,C'05',AND,40,19,CH,NE,C' '),                     
             OVERLAY=(1235:SEQNUM,8,ZD))     
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Mar 28, 2024 9:46 am    Post subject: Reply with quote

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
Code:

//STEP0100 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//INA      DD *                                             
00HKHKJLK                                                   
01JJKHLKJL                                                 
05HITHIS 0106876328762378798KJKJKJ;LK;L2344554444439990002 
02KLKJFLJ                                                   
05HITHIS 0106876328788378798KJKJAAA                         
05HITHIS 0106876328788378798KJKJKJ;LK;L2344554444439990333 
09NJKJLKJ                                                   
//INB      DD *                                             
1234567891000022000 2344554444439990002                     
1234567891000022002 2344554444439990402                     
1234567891000022005 2344554444439990023                     
//SORTOUT  DD SYSOUT=*                                     
//SYSIN    DD *                                             
  JOINKEYS F1=INA,FIELDS=(1235,8,A)                         
  JOINKEYS F2=INB,FIELDS=(0001,8,A)                         
  JOIN UNPAIRED,F1                                         
  REFORMAT FIELDS=(F1:0001,1234,                           
                      ?,                                   
                   F2:09,40)                               
                                                           
                                                           
  INREC IFOUTLEN=1234,                                     
          IFTHEN=(WHEN=(1235,01,CH,EQ,C'B'),               
               OVERLAY=(10:1237,19,                         
                        40:40,19,CHANGE=(19,C' ',C' '),     
                                NOMATCH=(1257,19)))         
                                                           
  SORT FIELDS=(1225,08,CH,A)                               
  OUTREC BUILD=(01,1224)                                   
/*                                                         
//JNF1CNTL DD *                                             
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(1225:SEQNUM,8,ZD)),     
        IFTHEN=(WHEN=(01,02,CH,EQ,C'05'),                   
             OVERLAY=(1235:SEQNUM,8,ZD))                   
/*                                                         
//JNF2CNTL DD *                                             
  INREC BUILD=(SEQNUM,8,ZD,X,01,40)                         
/*                                                         


and go look at the 2nd 05 record and tell me that field 40 is not spaces.
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Srishti Rawat
Beginner


Joined: 03 Nov 2021
Posts: 20
Topics: 6

PostPosted: Tue Apr 02, 2024 8:55 am    Post subject: Reply with quote

Hi Kolusu,

I made some changes in the positions that's why it wasn't working for me. This code is working.

Thanks a lot for your guidance, I learn a lot from here.

Thanks & Regards,
Srishti Rawat.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Wed Apr 03, 2024 12:01 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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