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

ISREDIT Macro is not returning back to the Rexx exec


IBM Mainframe Forums -> CLIST & REXX
Post new topic   This topic is locked: you cannot edit posts or make replies.
View previous topic :: View next topic  
Author Message
nico_neoz

New User


Joined: 02 Apr 2016
Posts: 18
Location: India

PostPosted: Sat Nov 18, 2017 7:40 pm
Reply with quote

I am invoking a personalized macro via rexx in order to edit members in a pds. The below code is how I execute the macro
Code:

ADDRESS ISPEXEC "EDIT DATASET('"SRCDS"("MEM1")') MACRO(ABC1)"

Here SRCDS is the dataset whose members I need to run the macro on.
MEM1 is the specific member and ABC1 is the macro. The MACRO is being called and is executing perfectly, but it stays in the member until I come out of it and then it executes the remaining part of REXX code.
BELOW is the MACRO
Code:

ISREDIT MACRO
"ISREDIT EXCLUDE ' '"
.
.
.
"ISREDIT DELETE ALL X"
.
.
"ISREDIT  RESET"
RETURN

Please clarify if I have given the incorrect return statement in the macro so that it executes without halting at the member waiting for me to come out of them.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


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

PostPosted: Sat Nov 18, 2017 8:04 pm
Reply with quote

I don't believe that RETURN is a valid Edit command; you'll want to use END (to save your changes) or CANCEL (to not save them) instead.
Back to top
View user's profile Send private message
nico_neoz

New User


Joined: 02 Apr 2016
Posts: 18
Location: India

PostPosted: Sat Nov 18, 2017 8:51 pm
Reply with quote

Akatsukami wrote:
I don't believe that RETURN is a valid Edit command; you'll want to use END (to save your changes) or CANCEL (to not save them) instead.


So should it be
Code:

"ISREDIT END"

or
Code:

END


I tried with "ISREDIT END" but that did not execute the MACRO. How do I identify the error code return in such case, as the rexx executed successfully with RC=0. Please help on this.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


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

PostPosted: Sat Nov 18, 2017 9:39 pm
Reply with quote

You definitely need to use ISREDIT END; END is also a Rexx instruction and, if not directed to the ISREDIT environment, will be (mis)interpreted by Rexx.

I find it peculiar that adding the END command causes the macro not to be executed. I recommend adding a trace statement at the beginning of your macro and, if you cannot interpret the trace, posting it here.
Back to top
View user's profile Send private message
nico_neoz

New User


Joined: 02 Apr 2016
Posts: 18
Location: India

PostPosted: Sat Nov 18, 2017 10:30 pm
Reply with quote

Akatsukami wrote:
You definitely need to use ISREDIT END; END is also a Rexx instruction and, if not directed to the ISREDIT environment, will be (mis)interpreted by Rexx.

I find it peculiar that adding the END command causes the macro not to be executed. I recommend adding a trace statement at the beginning of your macro and, if you cannot interpret the trace, posting it here.


Thank you for your suggestion ! Added a TRACE I just after the ISREDIT MACRO command, it's working then. But if I remove the trace command, it's not.

What might be the probable issue ?
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 712
Location: Denmark

PostPosted: Mon Nov 20, 2017 3:25 pm
Reply with quote

Have your edit macro (ABC1) do a SAVE before the END if you want to keep changes, otherwise do a CANCEL.
An END with outstanding modifications will cause an error as I recall.
Back to top
View user's profile Send private message
nico_neoz

New User


Joined: 02 Apr 2016
Posts: 18
Location: India

PostPosted: Mon Nov 20, 2017 4:09 pm
Reply with quote

Willy Jensen wrote:
Have your edit macro (ABC1) do a SAVE before the END if you want to keep changes, otherwise do a CANCEL.
An END with outstanding modifications will cause an error as I recall.


Hi Willy , tried as you suggested. Still the macro remains un executed. But if I add a trace command, it is executing successfully.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Mon Nov 20, 2017 5:25 pm
Reply with quote

it works for me ... as

Code:

/*  REXX 
    unpacks packed members
*/
Trace "O"

Parse Source _sys _how _cmd .

If Sysvar(SYSISPF) /= "ACTIVE" Then Do
   Say left(_cmd,8)"- Ispf is not active. Command not executed"
   Exit 4
End

Address ISPEXEC "CONTROL ERRORS RETURN"

Address ISREDIT "MACRO (ZPARMS) NOPROCESS "
if RC /= 0 then do
   zerrsm = "Invocation ERROR"
   zerrlm = left(_cmd,8)"- Must be invoked as an edit macro"
   Address ISPEXEC "SETMSG MSG(ISRZ002) "
   Exit 1
end

Address ISREDIT "(PACK) = PACK "
if pack = "ON" then do
   Address ISREDIT "PACK OFF"
   Address ISREDIT "END"
end
else do
   Address ISREDIT "CANCEL"
end

exit
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


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

PostPosted: Mon Nov 20, 2017 7:28 pm
Reply with quote

nico_neoz wrote:
Willy Jensen wrote:
Have your edit macro (ABC1) do a SAVE before the END if you want to keep changes, otherwise do a CANCEL.
An END with outstanding modifications will cause an error as I recall.


Hi Willy , tried as you suggested. Still the macro remains un executed. But if I add a trace command, it is executing successfully.

How are you determining that it does not execute?
Back to top
View user's profile Send private message
nico_neoz

New User


Joined: 02 Apr 2016
Posts: 18
Location: India

PostPosted: Mon Nov 20, 2017 8:42 pm
Reply with quote

enrico-sorichetti wrote:
it works for me ... as

Code:

/*  REXX 
    unpacks packed members
*/
Trace "O"

Parse Source _sys _how _cmd .

If Sysvar(SYSISPF) /= "ACTIVE" Then Do
   Say left(_cmd,8)"- Ispf is not active. Command not executed"
   Exit 4
End

Address ISPEXEC "CONTROL ERRORS RETURN"

Address ISREDIT "MACRO (ZPARMS) NOPROCESS "
if RC /= 0 then do
   zerrsm = "Invocation ERROR"
   zerrlm = left(_cmd,8)"- Must be invoked as an edit macro"
   Address ISPEXEC "SETMSG MSG(ISRZ002) "
   Exit 1
end

Address ISREDIT "(PACK) = PACK "
if pack = "ON" then do
   Address ISREDIT "PACK OFF"
   Address ISREDIT "END"
end
else do
   Address ISREDIT "CANCEL"
end

exit


Hi Enrico

My rexx starts with a "ISREDIT" instead of Address ISREDIT. Is that the reason why I am facing this issue ?
Back to top
View user's profile Send private message
nico_neoz

New User


Joined: 02 Apr 2016
Posts: 18
Location: India

PostPosted: Mon Nov 20, 2017 8:44 pm
Reply with quote

Akatsukami wrote:
nico_neoz wrote:
Willy Jensen wrote:
Have your edit macro (ABC1) do a SAVE before the END if you want to keep changes, otherwise do a CANCEL.
An END with outstanding modifications will cause an error as I recall.


Hi Willy , tried as you suggested. Still the macro remains un executed. But if I add a trace command, it is executing successfully.

How are you determining that it does not execute?


The members on which I am calling the macro remains un edited. Adding a trace i or trace r command is executing it, but it's not working if I remove that.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Mon Nov 20, 2017 8:50 pm
Reply with quote

why don' t You try to modify Your macro according to the style of my macro ?

start with an empty macro
add a couple of lines at the time to see what is going on
sprinkle the macro with "say something" to see the progress

it is odd anyway that something works/does not work simply because TRACE is on/off
Back to top
View user's profile Send private message
nico_neoz

New User


Joined: 02 Apr 2016
Posts: 18
Location: India

PostPosted: Mon Nov 20, 2017 8:55 pm
Reply with quote

enrico-sorichetti wrote:
why don' t You try to modify Your macro according to the style of my macro ?

start with an empty macro
add a couple of lines at the time to see what is going on
sprinkle the macro with "say something" to see the progress

it is odd anyway that something works/does not work simply because TRACE is on/off


Noted Enrico. My macro is primarily a series of EXCLUDE commands with a DELETE ALL X in the last. Will add a couple of debug say statements and let you know the result.
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 712
Location: Denmark

PostPosted: Mon Nov 20, 2017 9:42 pm
Reply with quote

I did a small test, this works for me:
Code:
 /* rexx */                         
 Address Isredit "MACRO NOPROCESS"   
 Address Isredit                     
 "x 'not' all"                       
 "(n) = exclude_counts"             
 if n=0 then do                     
   "cancel"                         
   exit 0                           
 end                                 
 "delete all x"                     
 "save"                             
 "end"                               
 exit 0

and perhaps use TRACE R instead of TRACE I, at least initially
Back to top
View user's profile Send private message
nico_neoz

New User


Joined: 02 Apr 2016
Posts: 18
Location: India

PostPosted: Tue Nov 21, 2017 9:07 am
Reply with quote

Willy Jensen wrote:
I did a small test, this works for me:
Code:
 /* rexx */                         
 Address Isredit "MACRO NOPROCESS"   
 Address Isredit                     
 "x 'not' all"                       
 "(n) = exclude_counts"             
 if n=0 then do                     
   "cancel"                         
   exit 0                           
 end                                 
 "delete all x"                     
 "save"                             
 "end"                               
 exit 0

and perhaps use TRACE R instead of TRACE I, at least initially


I modified the code in the above fashion and ran it adding a trace R in the starting. There was an RC 4 for the first member. But the second member went on fine. What does RC 4 corresponds to ?
Back to top
View user's profile Send private message
nico_neoz

New User


Joined: 02 Apr 2016
Posts: 18
Location: India

PostPosted: Tue Nov 21, 2017 10:43 am
Reply with quote

nico_neoz wrote:
Willy Jensen wrote:
I did a small test, this works for me:
Code:
 /* rexx */                         
 Address Isredit "MACRO NOPROCESS"   
 Address Isredit                     
 "x 'not' all"                       
 "(n) = exclude_counts"             
 if n=0 then do                     
   "cancel"                         
   exit 0                           
 end                                 
 "delete all x"                     
 "save"                             
 "end"                               
 exit 0

and perhaps use TRACE R instead of TRACE I, at least initially


I modified the code in the above fashion and ran it adding a trace R in the starting. There was an RC 4 for the first member. But the second member went on fine. What does RC 4 corresponds to ?



Excerpt from IBM Support website
"A macro can issue the return codes shown here. These return codes affect the command line and cursor position on the next display of edit data:

0
Shows normal completion of the macro. The cursor position is left as set by the macro. The command line is blanked.
1
Shows normal completion of the macro. The cursor is placed on the command line and the line is blanked. Use this return code to make it easy to enter another macro or edit command on the command line.
4 and 8
Treated by the ISPF editor as return code 0. No special processing is done.
"

Can someone please explain me the difference between return code 0 & 4.
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 712
Location: Denmark

PostPosted: Tue Nov 21, 2017 2:35 pm
Reply with quote

Quote:
please explain me the difference between return code 0 & 4

Certainly, it is 4 icon_biggrin.gif
You need to find the command which sets the rc 4, the trace r should tell you that, though you really should have a rc handler following each important statement. The meaning of a rc is found in the description of the command.
The EXCLUDE will set rc 4 if the string is not found, so I guess that is what you see. But you really should read the manual.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Tue Nov 21, 2017 3:08 pm
Reply with quote

probably the TS wondered why I exited with a 4 return code..
he should have noticed that it is a return code when the script runs OUTSIDE of the ISPF environment
Back to top
View user's profile Send private message
nico_neoz

New User


Joined: 02 Apr 2016
Posts: 18
Location: India

PostPosted: Wed Nov 22, 2017 9:36 am
Reply with quote

enrico-sorichetti wrote:
probably the TS wondered why I exited with a 4 return code..
he should have noticed that it is a return code when the script runs OUTSIDE of the ISPF environment


Sorry enrico, I am not able to follow
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 712
Location: Denmark

PostPosted: Wed Nov 22, 2017 2:18 pm
Reply with quote

@ Nico_neoZ
To answer your question about rc 4 vs rc 0 (sorry, I now realize that I didi not really answer it in my previous post): there is no difference in this case. If you call a macro from the edit command line, the cursor will remain where the macro sets it if the macro ends with rc 0,4 or 8. Only in case of rc 1 and rc >11 (according to my test) will the cursor be placed on the edit command line. rc 12 and bigger will return a macro error.
But this has nothing to do with your original question. Did you try the proposed solutions?
Back to top
View user's profile Send private message
nico_neoz

New User


Joined: 02 Apr 2016
Posts: 18
Location: India

PostPosted: Wed Nov 22, 2017 2:27 pm
Reply with quote

Willy Jensen wrote:
@ Nico_neoZ
To answer your question about rc 4 vs rc 0 (sorry, I now realize that I didi not really answer it in my previous post): there is no difference in this case. If you call a macro from the edit command line, the cursor will remain where the macro sets it if the macro ends with rc 0,4 or 8. Only in case of rc 1 and rc >11 (according to my test) will the cursor be placed on the edit command line. rc 12 and bigger will return a macro error.
But this has nothing to do with your original question. Did you try the proposed solutions?


Ok.. Yes I did. It gave the same result. This is really confusing how a trace command is resulting in the execution of the macro.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Wed Nov 22, 2017 2:47 pm
Reply with quote

Quote:
Ok.. Yes I did. It gave the same result.


hard to believe!

topic locked, is getting nowhere

the forum has gazillion of WORKING examples
search with ISREDIT MACRO and click on Search for all terms
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies. View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
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
No new posts run rexx code with jcl CLIST & REXX 15
No new posts Execute secondary panel of sdsf with ... CLIST & REXX 1
Search our Forums:

Back to Top