View previous topic :: View next topic
|
Author |
Message |
nico_neoz
New User
Joined: 02 Apr 2016 Posts: 18 Location: India
|
|
|
|
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 |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1787 Location: Bloomington, IL
|
|
|
|
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 |
|
|
nico_neoz
New User
Joined: 02 Apr 2016 Posts: 18 Location: India
|
|
|
|
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
or
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 |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1787 Location: Bloomington, IL
|
|
|
|
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 |
|
|
nico_neoz
New User
Joined: 02 Apr 2016 Posts: 18 Location: India
|
|
|
|
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 |
|
|
Willy Jensen
Active Member
Joined: 01 Sep 2015 Posts: 734 Location: Denmark
|
|
|
|
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 |
|
|
nico_neoz
New User
Joined: 02 Apr 2016 Posts: 18 Location: India
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
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 |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1787 Location: Bloomington, IL
|
|
|
|
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 |
|
|
nico_neoz
New User
Joined: 02 Apr 2016 Posts: 18 Location: India
|
|
|
|
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 |
|
|
nico_neoz
New User
Joined: 02 Apr 2016 Posts: 18 Location: India
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
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 |
|
|
nico_neoz
New User
Joined: 02 Apr 2016 Posts: 18 Location: India
|
|
|
|
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 |
|
|
Willy Jensen
Active Member
Joined: 01 Sep 2015 Posts: 734 Location: Denmark
|
|
|
|
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 |
|
|
nico_neoz
New User
Joined: 02 Apr 2016 Posts: 18 Location: India
|
|
|
|
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 |
|
|
nico_neoz
New User
Joined: 02 Apr 2016 Posts: 18 Location: India
|
|
|
|
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 |
|
|
Willy Jensen
Active Member
Joined: 01 Sep 2015 Posts: 734 Location: Denmark
|
|
|
|
Quote: |
please explain me the difference between return code 0 & 4 |
Certainly, it is 4
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
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 |
|
|
nico_neoz
New User
Joined: 02 Apr 2016 Posts: 18 Location: India
|
|
|
|
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 |
|
|
Willy Jensen
Active Member
Joined: 01 Sep 2015 Posts: 734 Location: Denmark
|
|
|
|
@ 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 |
|
|
nico_neoz
New User
Joined: 02 Apr 2016 Posts: 18 Location: India
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
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 |
|
|
|