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

Replace the characters ‘ACT’ in every word with ‘MAS'


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
MARINA JOSEPH

New User


Joined: 11 Jun 2009
Posts: 61
Location: chennai

PostPosted: Tue Sep 22, 2009 5:34 pm
Reply with quote

Hi,


I have an array of strings in FSTRING.J.



Like ACT-POL-APPL-SEG-CNT, ACT-POL-DROPPED-CLM-CNT, ACT-POL-REINST-DATE etc..



Code:
IF POS_WORD <> 0 THEN                 

DO                                   

   FSTRING.J = WORD(STRING,POS_WORD-1)

   IF SUBSTR(FSTRING.J,1,3) = 'ACT'   

   OVERLAY( "MAS" ,"ACT")

   SAY FSTRING.J       



I need to replace the characters ‘ACT’ in every word with ‘MAS'.
Could somebody tell if the above approach is right?

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

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Tue Sep 22, 2009 5:47 pm
Reply with quote

You really do need to spend some more time on describing your problem, so please explain exactly what you want to do.

Is the source in a dataset, a single member of a PDS, all members in a PDS or what.

Are you saying that each entry in the stem FSTRING has multiple fields with multiple occurences of "ACT" as shown in your post, or is each element shown really a part of the stem, as shown below.

FSTRING.1 = ACT-POL-APPL-SEG-CNT
FSTRING.2 = ACT-POL-DROPPED-CLM-CNT
FSTRING.3 = ACT-POL-REINST-DATE
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Tue Sep 22, 2009 5:53 pm
Reply with quote

if it works it is right, but it does not mean that You could not do better

here is a better solution

Code:
f = "abc" ;
t = "xyz"
l = length(t)

s.1 = "abc"
s.2 = "abc1abc"
s.3 = "abc1abc22abc"
s.4 = "abc1abc22abc3333abc"
s.5 = "abc1abc22abc3333abc4444abc"
s.6 = "abc1abc22abc3333abc4444abc55555abc"
s.7 = "abc1abc22abc3333abc4444abc55555abc666666abc"
s.0 = 7

do   i = 1 to s.0
   w = S.I
   p = pos(f,W)
   do   while p > 0
      w = overlay(t,w,p,l)
      p = pos(f,w)
   end
   s.i = w
end

do   i = 1 to s.0
   say right(i,2) s.i
end
Back to top
View user's profile Send private message
MARINA JOSEPH

New User


Joined: 11 Jun 2009
Posts: 61
Location: chennai

PostPosted: Tue Sep 22, 2009 6:04 pm
Reply with quote

The source is in a single member of a PDS.

I am writing a MACRO which will read variables from a copybook and replace the string ACT to MAS. The variables have been read into a stem variable.

The second scenario is right.

FSTRING.1 = ACT-POL-APPL-SEG-CNT
FSTRING.2 = ACT-POL-DROPPED-CLM-CNT
FSTRING.3 = ACT-POL-REINST-DATE
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Tue Sep 22, 2009 6:06 pm
Reply with quote

Wouldn't an ISPF edit macro be a quicker and cleaner way to go ? Which would also cater for differing lengths of in and out ...
Code:

"ISREDIT C 'ACT-' 'MAS-' ALL"
"ISREDIT END"


Enrico, nice solution - almost the same as the one I was going to post until I saw that you had.
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 -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 2
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Search two or more word with FILEAID Compuware & Other Tools 15
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
Search our Forums:

Back to Top