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
 

 

Find And Replace in a member through Rexx

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

New User


Joined: 29 May 2008
Posts: 15
Location: CHENNAI

PostPosted: Thu Aug 20, 2009 7:24 pm    Post subject: Find And Replace in a member through Rexx
Reply with quote

Hi,

i am very new to the REXX environment and a beginner in it icon_smile.gif .
I Need to Find for a string "Ten" in a member and i need to replace the string "ten" to "ten||year", where year will be the current year captured from date .
i had used simple tso/edit commands but i am unable to get that done.
Code:
 /*REXX*/                                 
 DTE = DATE(S)                             
 YEAR= DELSTR(DTE,5,4)                     
 ADDRESS "ISREDIT"                         
 "EDIT 'Q02587.NAFIN.CNTLCARD(SAS1099)'"   
 "F TEN"                                   
 IF RC=0 THEN                             
 "TSO CHANGE TEN TEN||"YEAR""             
 ELSE                                     
 SAY 'NOT FOUND'                           

I had captured the date and extracted the Year from it .
when i tried to edit the dataset i was not able to change it.
the dataset contains
Code:
PUT 'Q02587.TEN.LASERPRT'  PROD.TXT


i want the output to be
Code:
'q02587.ten2009.laserprt' prod.txt



can anybody assist me in addressing this.
Back to top
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Thu Aug 20, 2009 7:33 pm    Post subject:
Reply with quote

The ISPF edit macro manual is easily reached by using the button clearly marked "IBM Manuals" at the top of each page.

Along with the REXX manuals too.
Back to top
View user's profile Send private message
Pedro

Senior Member


Joined: 01 Sep 2006
Posts: 2033
Location: Silicon Valley

PostPosted: Thu Aug 20, 2009 7:34 pm    Post subject: Reply to: Find And Replace in a member through Rexx
Reply with quote

Quote:
when i tried to edit the dataset i was not able to change it.

Can you provide details of the problem you are seeing?

Your change command is not correct:
Code:
"CHANGE TEN TEN"||YEAR
 

1. The vertical bars are part of rexx syntax, not part of the CHANGE syntax.
2. so put bars and YEAR outside of the quotes.
3. REXX will perform concatenation and resolve variable before passing it to CHANGE.
Back to top
View user's profile Send private message
pnr kishore

New User


Joined: 29 May 2008
Posts: 15
Location: CHENNAI

PostPosted: Thu Aug 20, 2009 7:43 pm    Post subject:
Reply with quote

In the output i can see the dispaly as "not found", i guess else part is coming .
"F TEN" command has return code 20 hence else part is displayed.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Aug 20, 2009 7:52 pm    Post subject:
Reply with quote

Code:

"EDIT 'Q02587.NAFIN.CNTLCARD(SAS1099)'"   
 "F TEN"


the find command (F TEN) is not being executed against Q02587.NAFIN.CNTLCARD(SAS1099).

when you invoke an EDIT session, your find command has to be in a rexx script that is invoked via Imacro (which is part of the EDIT command syntax)
Back to top
View user's profile Send private message
pnr kishore

New User


Joined: 29 May 2008
Posts: 15
Location: CHENNAI

PostPosted: Thu Aug 20, 2009 8:20 pm    Post subject:
Reply with quote

thanks A lot icon_smile.gif
this has worked , i had created one macro in which
i have place all the find and replace commands and executed
the job got successful.

but how can we use in the Batch mode.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Fri Aug 21, 2009 11:47 am    Post subject:
Reply with quote

Running ISPF commands in batch is debated to death on the forum. Take a look and see.
Back to top
View user's profile Send private message
superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4648
Location: Raleigh, NC, USA

PostPosted: Fri Aug 21, 2009 6:25 pm    Post subject: Reply to: Find And Replace in a member through Rexx
Reply with quote

pnr kishore, going back to your original topic, there are a few considerations you need to know.

When you use TSO EDIT in a REXX exec, as opposed to a CLIST, you need to place all of the edit commands onto the data stack before you call the EDIT command. The FIND command will move the pointer to the row where the text is located, and then the CHANGE command will be in effect for that row. If the FIND command doesn't locate the text, then the CHANGE command will not work. You could've just done the EDIT manually once and then copied the sequence of commands in your exec. You can use the OUTTRAP command in REXX to store any EDIT messages and take the appropriate action.

A few changes to your code would've made it work correctly:

Code:

DTE = DATE(S)                             
YEAR= DELSTR(DTE,5,4)
QUEUE "TOP"                             
QUEUE "F =TEN="                         
QUEUE "C * =TEN=TEN"YEAR"="             
QUEUE "TOP"                             
QUEUE "END SAVE"                       
CALL OUTTRAP(ED.)                       
"EDIT 'Q02587.NAFIN.CNTLCARD(SAS1099)' TEXT ASIS NONUM"
CALL OUTTRAP(OFF)
"DELSTACK"
IF ED.0 > 0 THEN                 
  DO                             
    SAY 'EDIT ERROR:'             
    DO I = 1 TO ED.0             
      SAY ED.I                   
    END                           
  END                             
EXIT
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 REXX cdoe to purge a JOB from spool a... Sulabh Agrawal CLIST & REXX 11 Thu Mar 09, 2017 11:36 am
No new posts Browsing member from any PDS shiitiizz CLIST & REXX 7 Wed Mar 08, 2017 1:17 am
No new posts Overriding PS data in rexx Shaheen Shaik CLIST & REXX 8 Fri Mar 03, 2017 5:08 pm
No new posts Bind plan as a member to another bind... rexx77 DB2 0 Thu Feb 16, 2017 2:02 am
No new posts REXX compiled via RXTCOMP sergeyken CLIST & REXX 7 Tue Feb 07, 2017 9:41 pm


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