Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Replace the characters ‘ACT’ in every word with ‘MAS'

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
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    Post subject: Replace the characters ‘ACT’ in every word with ‘MAS'
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: 8620
Location: Back in jolly old England

PostPosted: Tue Sep 22, 2009 5:47 pm    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10375
Location: italy

PostPosted: Tue Sep 22, 2009 5:53 pm    Post subject: Reply to: REPLACE A STRING
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    Post subject: Reply to: REPLACE A STRING
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: 8620
Location: Back in jolly old England

PostPosted: Tue Sep 22, 2009 6:06 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts line 52: Name or string > 250 char... Ashishpanpaliya CLIST & REXX 5 Sat Oct 14, 2017 2:29 am
No new posts Binary to display characters Roy Ware SYNCSORT 3 Tue Sep 19, 2017 8:46 pm
No new posts Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
No new posts Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm
No new posts Remove junk values in a file and rite... KP1125 DFSORT/ICETOOL 2 Wed Jan 25, 2017 9:58 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us