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

Issue with - Passing Return code to JCL step from Rexx


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
skpanda

New User


Joined: 08 Dec 2014
Posts: 6
Location: USA

PostPosted: Tue Dec 09, 2014 11:33 am
Reply with quote

Hi All,

I have an issue related to 'passing Return Code from Rexx to the JCL that executes the Rexx'.

This exact topic/issue is discussed at the below thread. However, after doing all that, i still have the issue. Not sure what I am missing.

As per the forum rules, I am opening a new thread (instead of replying to the old 2007 thread).

Reference to the old thread:

ibmmainframes.com/about29834.html


Situation:
I am executing a Rexx (Say RexxPGM) from a JCL using IKJEFT01. Note that in JCL parm I am giving REXXStrt rexx program which in turn has ISPSTART CMD (RexxPgm parms). Under certain conditions (in the Rexx), I want to pass a return code to the JCL step so that it can abend with that return code. In this case I want to set it to 12. I have EXIT 12 coded in the Rexx for this situation.

What I have tried:
a. After doing some research, I learnt that I can pass return code only if i use IKJEFT1A or IKJEFT1B. Therefore I changed this but it still did not work.

b. I tried setting RC=12 and then did EXIT RC. Did not work.

c. I followed the advise in the above thread and gave the below. Still did not work.

ZISPFRC = 12
Address ISPEXEC "VPUT (ZISPFRC)"

d. I tried IKJEFT01, IKJEFT1A and IKJEFT1B for b and c above.

In all the above cases, the step returns a return code of 0. However, I do see the Return code 12 in the spool. Just not what i want (JCL step gets RC12 and the job has return code of 12).

Please advise if you have any thoughts on resolving this issue.

I would be happy to provide any additional information.


Note: For now i have a temporary solution. I am writing a record into a new file in the Rexx program only when it is successful. In all other cases, the fill will be empty. I added a ICETOOL step after the IKJEFT01 step to count and if the file is empty, i am setting the return code of the ICETOOL step to 12. However, I want to avoid this temporary solution and be able to set the Return code of 12 in the IKJEFT01/IKJEFT1A step.

Thanks in advance!!
Back to top
View user's profile Send private message
Paul Voyner

New User


Joined: 26 Nov 2012
Posts: 52
Location: UK

PostPosted: Tue Dec 09, 2014 2:25 pm
Reply with quote

Hi, I read this sentence a few times but can't make sense of it

Quote:
In all the above cases, the step returns a return code of 0. However, I do see the Return code 12 in the spool. Just not what i want (JCL step gets RC12 and the job has return code of 12).


So does the step end with 0 or 12 ? Maybe what you really need here is JOBRC=MAXRC on the jobcard
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Tue Dec 09, 2014 3:00 pm
Reply with quote

You're doing better than me Paul, I can't make sense of the whole post icon_razz.gif

skpanda can you explain more clearly exactly what you want to do.

You CAN NOT set a value to RC. The manual states that this is a READ ONLY variable.

If you set another variable in the REXX that retains the value you want you can use that, maybe as EXIT (var_name) or along the lines of if var_name = 12 then EXIT(12)

Also be aware that ISPF uses a different set of variables - ZISPFRC if I remember correctly
Back to top
View user's profile Send private message
skpanda

New User


Joined: 08 Dec 2014
Posts: 6
Location: USA

PostPosted: Tue Dec 09, 2014 9:23 pm
Reply with quote

Thanks for your response and sorry for the confusion.

I will try to explain with some code that i have:

1. JCL to execute the Rexx:

//REXTSO EXEC PGM=IKJEFT01,COND=(8,LT),DYNAMNBR=30,
// PARM=('STARTPGM parm_values_for_rexx')


2. STARTPGM Rexx:

This is just a temporary Rexx program to trigger the actual Rexx program using ISPSTART.

'ISPSTART CMD(%MYREXXPG 'parm_values_for_rexx')'


3. MYREXXPG Rexx program

This is my actual Rexx Program. In this program i check some conditions and decide the return code that i want to pass to the JCL step.

IF (condition_fail) THEN
DO
RTNCD = 12
ZISPFRC = 12
ADDRESS ISPEXEC "VPUT (ZISPFRC)"
END
ELSE
DO
RTNCD = 0
END

EXIT RTNCD


4. Expected Result:

When condition_fail is true, the JCL step REXTSO should have a Return code of 12. Spool should show below.

PGM=IKJEFT01 00:00:01.02 EXEC TIME 00.98% CPU RC= 12


5. Actual Result:

SYSTSPRT shows below:

ISPD117
The initially invoked CLIST ended with a return code = 12
+++ RC(12) +++


JCL Step REXTSO gives a return code of 0.

PGM=IKJEFT01 00:00:01.02 EXEC TIME 00.98% CPU RC= 00

I tried to change IKJEFT01 to IKJEFT1A/IKJEFT1B but i have the the same result.

I hope this is clear. Kindly let me know if you need any additional information.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Tue Dec 09, 2014 9:52 pm
Reply with quote

Why bother with the Startpgm bit ....... you can put that into the parm anyway

Have you ran the REXX using trace
Back to top
View user's profile Send private message
Paul Voyner

New User


Joined: 26 Nov 2012
Posts: 52
Location: UK

PostPosted: Tue Dec 09, 2014 9:55 pm
Reply with quote

Hi, thanks for taking the time to explain.

I think the problem is that you are setting RC in MYREXXPG, but control returns to TSO via STARTPGM, so STARTPGM is where you set the RC.

In MYREXXPG, the only return code that matters is the VPUT (ZISPFRC). RTNCD is doing nothing useful.

In STARTPGM, add RETURN RC i.e.
'ISPSTART CMD(%MYREXXPG 'parm_values_for_rexx')'
RETURN RC /* New */

Works for me !

You can also dispense with STARTPGM if you do PGM=IKJEFT1A,PARM='ISPSTART CMD(MYREXXPGM)'. This is where you see different behavior beween IKJEFT01 & 1A/1B
Back to top
View user's profile Send private message
skpanda

New User


Joined: 08 Dec 2014
Posts: 6
Location: USA

PostPosted: Tue Dec 09, 2014 10:07 pm
Reply with quote

expat wrote:
Why bother with the Startpgm bit ....... you can put that into the parm anyway

Have you ran the REXX using trace


Thanks... for the quick response.

Startpgm - do you suspect that is causing the problem?

Trace: i am familiar with running trace in realtime like TSO MYREXXPG and it shows panel etc..
How do i do it in batch...kindly point me in that direction (i did not some quick googling and also in the forum.. i do not seem to find the exact way to do it).
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Tue Dec 09, 2014 10:11 pm
Reply with quote

IIRC a non 0 rc in an ispf Invoked thing will cause an ISPF error

try RETURN 0
Back to top
View user's profile Send private message
skpanda

New User


Joined: 08 Dec 2014
Posts: 6
Location: USA

PostPosted: Tue Dec 09, 2014 10:21 pm
Reply with quote

Paul Voyner wrote:
Hi, thanks for taking the time to explain.

I think the problem is that you are setting RC in MYREXXPG, but control returns to TSO via STARTPGM, so STARTPGM is where you set the RC.

In MYREXXPG, the only return code that matters is the VPUT (ZISPFRC). RTNCD is doing nothing useful.

In STARTPGM, add RETURN RC i.e.
'ISPSTART CMD(%MYREXXPG 'parm_values_for_rexx')'
RETURN RC /* New */

Works for me !

You can also dispense with STARTPGM if you do PGM=IKJEFT1A,PARM='ISPSTART CMD(MYREXXPGM)'. This is where you see different behavior beween IKJEFT01 & 1A/1B



Thanks a lot.. this was perfect... it worked...
Back to top
View user's profile Send private message
skpanda

New User


Joined: 08 Dec 2014
Posts: 6
Location: USA

PostPosted: Tue Dec 09, 2014 10:21 pm
Reply with quote

enrico-sorichetti wrote:
IIRC a non 0 rc in an ispf Invoked thing will cause an ISPF error

try RETURN 0


Thanks..

but i did not understand, where you wanted me to use RETURN 0. Kindly elaborate.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Tue Dec 09, 2014 10:34 pm
Reply with quote

in general it is a good practice to use return instead of exit

anyway when You are leaving/terminating/finished with an ISPF invoked script

You have to return/exit with a RC of 0

otherwise as You have already seen ISPF will not give a sith about the setting of the ZISPFRC

and do it' s own processing for a command terminated in error
Back to top
View user's profile Send private message
skpanda

New User


Joined: 08 Dec 2014
Posts: 6
Location: USA

PostPosted: Wed Dec 10, 2014 11:00 am
Reply with quote

Thanks all for quick and prompt response... I was able to resolve my issue!!

Cheers!
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 Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
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
Search our Forums:

Back to Top