View previous topic :: View next topic
|
Author |
Message |
pnr kishore
New User
Joined: 29 May 2008 Posts: 15 Location: CHENNAI
|
|
|
|
Hi,
i am very new to the REXX environment and a beginner in it .
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 |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
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 |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2547 Location: Silicon Valley
|
|
|
|
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 |
|
|
pnr kishore
New User
Joined: 29 May 2008 Posts: 15 Location: CHENNAI
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
pnr kishore
New User
Joined: 29 May 2008 Posts: 15 Location: CHENNAI
|
|
|
|
thanks A lot
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 |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Running ISPF commands in batch is debated to death on the forum. Take a look and see. |
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
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 |
|
|
|