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

Search and replace all similar string in PS using REXX


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
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
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: 1788
Location: Bloomington, IL

PostPosted: Sat Oct 06, 2012 6:28 pm
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Sat Oct 06, 2012 9:08 pm
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: 2455
Location: Hampshire, UK

PostPosted: Sun Oct 07, 2012 3:18 pm
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
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: 1788
Location: Bloomington, IL

PostPosted: Sun Oct 07, 2012 7:31 pm
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: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Sat Dec 08, 2012 9:32 pm
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: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Sat Dec 08, 2012 9:34 pm
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Sat Dec 08, 2012 10:15 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
Search our Forums:

Back to Top