Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Search and replace all similar string in PS using REXX

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
sathyak

New User


Joined: 06 Oct 2012
Posts: 2
Location: india

PostPosted: Sat Oct 06, 2012 4:37 pm    Post subject: Search and replace all similar string in PS using REXX
Reply with quote

Hi All,

I am new to REXX. Please help me,

example:
STM.PARM(PSFILE) [my ps file]
&sathya [string in ps file occurs many times]

I need to replace all this &sathya with new string am getting as a input from user through REXX.

I dont know about MACROS in REXX. Need example code.
[/b]
Back to top
View user's profile Send private message

Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Sat Oct 06, 2012 6:28 pm    Post subject:
Reply with quote

I won't have access to a mainframe until Monday, so I'll be doing some handwaving, and any code I offer until then will be untested. Having said so much, are you looking for a Rexx script, to be run from the TSO READY prompt or the ISPF command line, or an edit macro written in Rexx?
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Sat Oct 06, 2012 9:08 pm    Post subject: Reply to: Search and replace all similar string in PS using
Reply with quote

Quote:
I dont know about MACROS in REXX. Need example code.


what happened when You searched the forum for examples ?
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1717
Location: UK

PostPosted: Sun Oct 07, 2012 3:18 pm    Post subject:
Reply with quote

What happened when you read the "ISPF Edit and Edit Macros"? Did your eyes glaze over (like mine do with the DFSort manual!)?
Back to top
View user's profile Send private message
sathyak

New User


Joined: 06 Oct 2012
Posts: 2
Location: india

PostPosted: Sun Oct 07, 2012 4:39 pm    Post subject: Reply to: Search and replace all similar string in PS using
Reply with quote

I have found Some code to replace string in ps. USING STEM

===================================================

/*REXX*/
INFILE = STR.REP.TEST

ADDRESS TSO
"ALLOC FI(INFIL) DA('"INFILE"') SHR REUSE"
"EXECIO * DISKR INFIL (STEM OUT. FINIS"
"FREE FI(INFIL)"

DO I=1 TO OUT.0
A=OUT.I
A=STRRPL(A,'&TEXT','NEWTEXT')
REP.I=A

"ALLOC FI(OUTFI) DA('"INFILE"') SHR REUSE"
"EXECIO * DISKR OUTFI (STEM REP. FINIS"
"FREE FI(OUTFI)"

END

STRRPL:

ORIG=ARG(1)
OLD=ARG(2)
NEW=ARG(3)
NEWSTR = ORIG

DO WHILE POS(OLD,NEWSTR)-1) || ,
NEW || SUBSTR(NEWSTR,POS(OLD,NEWSTR) + LENGTH(OLD))
END

RETURN NEWSTR


=============================================
Its working with PS files. but not with PDS MEMBER.

Other then MACRO is there any possiblities to do this for PDS MEMBER.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Sun Oct 07, 2012 7:31 pm    Post subject: Reply to: Search and replace all similar string in PS using
Reply with quote

  1. In the future, enclose your code (and anything else where alignment can be significant) in Code tags. Both the Quick and ordinary reply screen have a Code button, which places an open Code tag at the cursor position; you can then paste after it and click on the Close Tags link.
    Code:
    Code text looks like        this
    Note that extra spaces are preserved.
  2. In the future, do not merely post, "It didn't work!"; we can deduce that from the fact that you are posting here. Give us the information that we need to diagnose the problem and recommend to you how to correct it: message numbers and text, and return and abend codes.
  3. Apropos of the last, a sine qua non for debug Rexx scripts is a trace. Place either TRACE I (which shows intermediate results for your statements) or TRACE R (which shows only final results) immediately before the point where you wish to begin tracing; place TRACE O if you wish to turn off the trace before the end of the script.
  4. The code you show is very obviously for a physical sequential (PS) data set; we need to see what changes you made attempting to adapt it to work with a PDS.
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Sat Dec 08, 2012 9:32 pm    Post subject:
Reply with quote

For a PDS you will need your main REXX script which will call another rexx macro to edit your PDS members..

Here I have written one..But I can't test it until Monday.


CHANGSTR


Code:


/******************REXX*******************/                             
ISREDIT "MACRO PROCESS"                                                 

MDSN = 'YOUR.PDS.NAME'
INPUT1 = 'STRING1'                                                       
INPUT2 = 'STRING2'                                                       

IF INPUT1 \= ' ' THEN                                           
  DO                                                           
    IF INPUT2 \= ' ' THEN                                     
      DO                                                     
        IF SYSDSN(MDSN) = "OK" THEN                       
           "ISPEXEC VPUT (INPUT1) SHARED"                 
           "ISPEXEC VPUT (INPUT2) SHARED"                 
           X=OUTTRAP('N.')                                 
           SAY MDSN                                       
           "LISTDS" MDSN "MEMBER"                         
           X=OUTTRAP('OFF')                               
           SAY "TOTAL" N.0-6 "MEMBERS OF",                 
                MDSN "TO BE PROCESSED.........."           
           DO I=7 TO N.0                                   
              MEM=STRIP(N.I,B)                               
              MYFILE=MDSN || '(' || MEM || ')'               
              ADDRESS ISPEXEC "EDIT DATASET("MYFILE") MACRO(IM001)" 
           END                                             
           DROP N.                                         
      END                                                   
  END                                                       



Macro IM001

Code:


/*REXX*/                       
ISREDIT "MACRO PROCESS"         

"ISPEXEC VGET (ENDEXEC) SHARED"
"ISPEXEC VGET (INPUT2) SHARED" 
"ISPEXEC VGET (INPUT1) SHARED" 

ISREDIT "C ALL " INPUT1 INPUT2 
ISREDIT "RESET "               
ISREDIT "END"                   

EXIT                           

Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Sat Dec 08, 2012 9:34 pm    Post subject:
Reply with quote

I'm too drunk to realize that I'm replying to a dead post :-)
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Sat Dec 08, 2012 10:15 pm    Post subject: Reply to: Search and replace all similar string in PS using
Reply with quote

Quote:
I'm too drunk to realize that I'm replying to a dead post :-)

well still pretty warm...
I' ve seen people replying to five years old posts
and before I split it somebody tailgating to a seven years old post
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 What is the command to check MODE of ... rohanthengal CLIST & REXX 6 Fri Nov 18, 2016 1:48 pm
This topic is locked: you cannot edit posts or make replies. Rexx to create GDG by scanning JJ result krish.deepu CLIST & REXX 5 Tue Oct 25, 2016 5:32 pm
No new posts Replace repeated JCL with looping REXX prino CLIST & REXX 3 Thu Oct 13, 2016 5:30 am
This topic is locked: you cannot edit posts or make replies. Need to code a Rexx PGM sundaram.naveen CLIST & REXX 18 Thu Oct 06, 2016 6:45 pm
This topic is locked: you cannot edit posts or make replies. Checking wether a string starts from ... sundaram.naveen CLIST & REXX 9 Thu Oct 06, 2016 11:56 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us