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

Find And Replace in a member through Rexx


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
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
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: 8797
Location: Welsh Wales

PostPosted: Thu Aug 20, 2009 7:33 pm
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

Global Moderator


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

PostPosted: Thu Aug 20, 2009 7:34 pm
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
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
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
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: 8797
Location: Welsh Wales

PostPosted: Fri Aug 21, 2009 11:47 am
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

Global Moderator


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

PostPosted: Fri Aug 21, 2009 6:25 pm
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 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 Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
Search our Forums:

Back to Top