IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

change string before sertan string


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
anatol

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

PostPosted: Tue Aug 15, 2017 5:43 pm
Reply with quote

Hi,

I have file (fb,80) where could be combination of AA or BB or CC or DD in any position ( only one combination per record) . Is it possible to change 3 position before combination to 111 if it is 000 there.

Input


Code:

00000000000000000AA111111111111111111       
22222222BB000000000000000000000             
             CC0000000000000000000000       
000000000000000000000000000DD111111111       


Output:

Code:

00000000000000111AA111111111111111111   
22222222BB000000000000000000000         
             CC0000000000000000000000   
000000000000000000000000111DD111111111 
Back to top
View user's profile Send private message
anatol

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

PostPosted: Tue Aug 15, 2017 6:26 pm
Reply with quote

Sorry, I read my post and understood, that you will probably suggest me to use FINDREP function .... but real case more complicated, then I define it initially ...in general - I need to work /change 3 position before combination of AA,BB,CC,DD
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Tue Aug 15, 2017 6:50 pm
Reply with quote

Can you tell us:

What is 'sertan'?? Do you mean to say 'certain' ??

What is your issue with FINDREP? Why can't you use that? What is real case which is supposed to be more complicated?

.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Tue Aug 15, 2017 7:18 pm
Reply with quote

Are you saying that there must be 4 records present (1 x AA, 1 x BB, 1 x CC and 1 x DD) before you can change 000AA to 111AA in that group of four?
If so, will there only be four records in the group to be changed?
Back to top
View user's profile Send private message
anatol

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

PostPosted: Tue Aug 15, 2017 7:49 pm
Reply with quote

sorry, it was typo with certain ...
I am saying that if combination of AA is in the record, then not other combinations as BB, CC etc in this record...

I cannot use FINDREP 000AA to 111AA because it is more complicated - it is not just change 000 to 111 ... it is in my request, but I need idea how to change 3 positions before combination .... it is not just 000 to 111 ...maybe better to explain .... I need to change 3 position before AA to 111 if this 3 positions NOT = 000 ... could be 123 or 321 or 1g1 ... so I cannot use FINDREP
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Tue Aug 15, 2017 8:26 pm
Reply with quote

You'll need to use PARSE to break your record into possibly 4 parts,

something similar to (not tested so may not be exactly what you want):
Code:
 INREC PARSE=(%00=(ENDBEFR=C'AA',FIXLEN=80),
       %01=(SUBPOS=5,ENDBEFR=C'AA',FIXLEN=3),
       %02=(STARTAFT=C'AA',FIXLEN=80)),     
       BUILD=(%00,%01,C'AA',%02)             


And then you can user OVERLAY to whatever condition you want on '000' or 'Not 000'. similar to:
Code:
 OUTREC IFTHEN=(WHEN=(81,3,CH,NE,C'000',AND,84,2,CH,EQ,C'AA'),
                  OVERLAY=(81:C'111'))


I am in a rush but I hope this may give you some idea.

.
Back to top
View user's profile Send private message
anatol

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

PostPosted: Tue Aug 15, 2017 9:08 pm
Reply with quote

Thank you, I will try
Back to top
View user's profile Send private message
magesh23586

Active User


Joined: 06 Jul 2009
Posts: 213
Location: Chennai

PostPosted: Tue Aug 15, 2017 9:57 pm
Reply with quote

Your condition is little confusing, any way below code may give you some insight.

Assuming LRECL=40

Code:

//SYSIN DD *                                                 
 OPTION COPY                                                 
 INREC  IFTHEN=(WHEN=INIT,                                   
                FINDREP=(INOUT=(C' ',C'~'))),               
                                                             
        IFTHEN=(WHEN=INIT,                                   
                PARSE=(%01=(ENDAT=C'AA',                     
                            ENDAT=C'BB',                     
                            ENDAT=C'CC',                     
                            ENDAT=C'DD',                     
                            FIXLEN=40),                       
                       %02=(FIXLEN=40)),                     
                BUILD=(%01,JFY=(SHIFT=RIGHT),%02)),         
                                                             
        IFTHEN=(WHEN=(39,2,SS,EQ,C'AA,BB,CC,DD',AND,         
                      36,3,CH,NE,C'000'),                   
                OVERLAY=(36:C'111'))                         
                                                             
 OUTREC IFTHEN=(WHEN=INIT,                                   
                BUILD=(1,80,SQZ=(SHIFT=LEFT))),
                                               
        IFTHEN=(WHEN=INIT,                     
                FINDREP=(INOUT=(C'~',C' '))), 
                IFOUTLEN=40                   
                                                                                                       


output :
Code:

00000000000000000AA111111111111111111     
22222111BB000000000000000000000           
          111CC0000000000000000000000     
000000000000000000000000000DD111111111     
Back to top
View user's profile Send private message
anatol

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

PostPosted: Tue Aug 15, 2017 10:28 pm
Reply with quote

wow, looks great ... I 'll try to understand it line by line.... thank you , it's very nice idea
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts 3270 personal communications. Can't c... TSO/ISPF 2
No new posts file manager is doing string conversion IBM Tools 3
No new posts SELECT from data change table DB2 5
Search our Forums:

Back to Top