Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

using if/then/else with return code
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
Alex Garcia

New User


Joined: 06 Jan 2011
Posts: 9
Location: Kansas City

PostPosted: Thu Jan 06, 2011 9:08 pm    Post subject: using if/then/else with return code
Reply with quote

I have a job that executes the same proc three times. The first step in the proc is a program that checks to see if a dataset is empty. If so, the program sets the rc=1. This step does not have a cond= on it. The first execution of the proc sets the return code to 1 and the rest of the steps are bypassed. The next execution of the proc executes the same program and sets the rc=0 since the input dataset is not empty, but the remaining steps in the proc do not run. The same result for the third execution of the proc. If the second and third execution of the program resets the rc to 0, why don't the rest of the steps execute?

Thanks!
Back to top
View user's profile Send private message

Akatsukami

Global Moderator


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

PostPosted: Thu Jan 06, 2011 9:20 pm    Post subject:
Reply with quote

Please post the JCL, including the expansion of the proc, and that portion of the JES execution log showing that the steps do not run. Cut and paste from your emulator, using the Code tag for readability; do not attach screenshots or other documents.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Jan 06, 2011 9:42 pm    Post subject:
Reply with quote

Hello,

Quote:
If the second and third execution of the program resets the rc to 0, why don't the rest of the steps execute?
Ahh, Umm, nothing resets an already set return code. . . New return codes occur as additonal steps execute, but once set the return code from previous steps are never reset.

If your process only executed the proc once (rather than three times), you could submit process 2 from process 1 and then process 3 from process 2 via the internal reader. Then the "original" return code would not be seen by the subsequent runs.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


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

PostPosted: Thu Jan 06, 2011 9:54 pm    Post subject:
Reply with quote

dick scherrer wrote:
Quote:
If the second and third execution of the program resets the rc to 0, why don't the rest of the steps execute?
Ahh, Umm, nothing resets an already set return code. . . New return codes occur as additonal steps execute, but once set the return code from previous steps are never reset.

If I understand him correctly (and it's quite possible I don't, which is why I asked to see the JCL and execution log) his JCL looks like this:

Code:
//A JOB
//STEP1 EXEC FOO
//STEP2 EXEC FOO
//STEP3 EXEC FOO
//

and FOO looks like
Code:
//FOO PROC
//PRCSTEP1 EXEC PGM=BAR
// IF (RC=0) THEN
//PRCSTEP2 EXEC PGM=SUMMAT
// ENDIF

STEP1.PRCSTEP1 runs to CC=1, and as expected STEP1.PRCSTEP2 does not execute. STEP2.PRCSTEP2 runs to CC=0, but STEP2.PRCSTEP2 does not execute as desired; likewise STEP3.PRCSTEP1 and STEP3.PRCSTEP2.

(The error in this case is obvious, but it may not be so in realitty.)
Back to top
View user's profile Send private message
Alex Garcia

New User


Joined: 06 Jan 2011
Posts: 9
Location: Kansas City

PostPosted: Thu Jan 06, 2011 9:57 pm    Post subject:
Reply with quote

Sorry, I misspoke. The first execution of the proc sets the rc=1 and the subsequent executions of the proc SETS the rc=0. Does the JCL keep three different return codes and only reference the first? This doesn't make sense since after rearranging the jobsteps so that a valid data card is first, the proc executed all the steps for the first execution and then the second got rc=1 and neither execution 2 or 3 executed
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7914
Location: Bellevue, IA

PostPosted: Thu Jan 06, 2011 10:00 pm    Post subject:
Reply with quote

Each step executed has a return code associated with it. A COND test that does not reference an individual step refers to all previous step condition codes.
Back to top
View user's profile Send private message
Alex Garcia

New User


Joined: 06 Jan 2011
Posts: 9
Location: Kansas City

PostPosted: Thu Jan 06, 2011 10:08 pm    Post subject:
Reply with quote

the job:
Code:

//FOO  job
//FOOA EXEC PROC OOF
//FOOB EXEC PROC OOF
//FOOC EXEC PROC OOF

The proc:
Code:

//OOF PROC
//STEP1 EXEC PGM=UTL090
//IF UTL090.RC = 0 THEN
//   EXEC ALL PROCSTEPS
//END-IF

The result:
FOOA executes, utl090 gets an rc=1 all steps in proc bypassed
FOOB executes, utl090 gets rc=0, all steps in proc bypassed
FOOC executes, utl090 gets rc=0, all steps in proc bypassed

UTL090 is the only step in the proc that does not have a COND=

thanks
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7914
Location: Bellevue, IA

PostPosted: Thu Jan 06, 2011 10:23 pm    Post subject:
Reply with quote

Would it be so hard to post the actual job expansion? Without seeing exactly what the system thinks you've done, I don't think we're going to be able to help you.
Back to top
View user's profile Send private message
Alex Garcia

New User


Joined: 06 Jan 2011
Posts: 9
Location: Kansas City

PostPosted: Thu Jan 06, 2011 10:34 pm    Post subject:
Reply with quote

I am not allowed to post stuff outside of work. They get kinda hinky about that stuff. The salient points are there. I think you answered my question with your earlier post about each step seeing the rc from each previous step. I assume that includes earlier executions of a proc in a job as well?
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


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

PostPosted: Thu Jan 06, 2011 10:59 pm    Post subject:
Reply with quote

Note that qualifying the return code with the program name is wrong; it has to be qualified with the step name.

There are other possible errors due to its being embedded in a proc, but I may or may not be able to turn my full attention to this for a few hours.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


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

PostPosted: Thu Jan 06, 2011 11:29 pm    Post subject:
Reply with quote

I did have some time to look at this.

As I'd thought, the qualification of the condition is wrong (as is the hyphen in "END-IF").

My JCL:
Code:
//FOOA EXEC   OOF 
//STEP1.TOOLIN DD *
1                 
//STEP2.SYSUT1 DD *
GOODBYE, WORLD!   
//FOOB EXEC    OOF
//STEP1.TOOLIN DD *
0                 
//STEP2.SYSUT1 DD *
GOODBYE, WORLD!   
//FOOC EXEC    OOF
//STEP1.TOOLIN DD *
0                 
//STEP2.SYSUT1 DD *
GOODBYE, WORLD!   

The proc OOF:
Code:
//OOF      PROC                           
//STEP1    EXEC PGM=P14                   
//         IF (STEP1.RC=0) THEN           
//STEP2    EXEC PGM=IEBGENER               
//SYSPRINT DD   SYSOUT=*                   
//SYSUT2   DD SYSOUT=*                     
//SYSIN    DD DUMMY                       
//         ENDIF                           

(P14 is a little utility that does nothing but set the completion code to whatever is read from TOOLIN, or to 1234 if that is not a valid return code.)

Results in (E)JES:
Code:
JESMSGLG                   HLD  1   6   1     LOCAL                     17
JESJCL                     HLD  1   6   1     LOCAL                     52
JESYSMSG                   HLD  1   6   1     LOCAL                    201
SYSPRINT FOOB     STEP2    HLD  1   6   1     LOCAL                     17
SYSUT2   FOOB     STEP2    HLD  1   6   1     LOCAL                      1
SYSPRINT FOOC     STEP2    HLD  1   6   1     LOCAL                     17
SYSUT2   FOOC     STEP2    HLD  1   6   1     LOCAL                      1

As expected and desired, FOOA.STEP2 did not execute, whereas FOOB.STEP2 and FOOC.STEP2 did.
Back to top
View user's profile Send private message
Alex Garcia

New User


Joined: 06 Jan 2011
Posts: 9
Location: Kansas City

PostPosted: Fri Jan 07, 2011 12:19 am    Post subject:
Reply with quote

Akatsukami wrote:
Note that qualifying the return code with the program name is wrong; it has to be qualified with the step name.


Sorry, in my jcl the stepname and program name are the same. I typed it in wrong. My bad. UTL090.rc=0 is the stepname. Not step1. Also, the hyphen only exists in what I typed. there is none in my exec jcl
Back to top
View user's profile Send private message
Alex Garcia

New User


Joined: 06 Jan 2011
Posts: 9
Location: Kansas City

PostPosted: Fri Jan 07, 2011 12:26 am    Post subject:
Reply with quote

The difference between your execution and mine is that your subsequent steps don't have a cond=. I still need to code for abend situations and not execute subsequent steps on critical abends. They are all coded
Code:
cond=(0,ne)
(with the exception of the utl090 step)
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7914
Location: Bellevue, IA

PostPosted: Fri Jan 07, 2011 12:37 am    Post subject:
Reply with quote

Quote:
A COND test that does not reference an individual step refers to all previous step condition codes.
Your COND=(0,NE) does not reference a step name, hence it applies to ALL PREVIOUS STEPS. If any step prior gets a non-zero return code, the execution of the step with COND=(0,NE) will be bypassed.

The system is doing exactly what you told it to do.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


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

PostPosted: Fri Jan 07, 2011 12:42 am    Post subject:
Reply with quote

Alex Garcia wrote:
The difference between your execution and mine is that your subsequent steps don't have a cond=. I still need to code for abend situations and not execute subsequent steps on critical abends. They are all coded
Code:
cond=(0,ne)
(with the exception of the utl090 step)

Nu? Change the relational expression to ((STEP1.RC = 0) & (┬ČABEND)).
Back to top
View user's profile Send private message
Alex Garcia

New User


Joined: 06 Jan 2011
Posts: 9
Location: Kansas City

PostPosted: Fri Jan 07, 2011 2:25 am    Post subject:
Reply with quote

Robert Sample wrote:
]Your COND=(0,NE) does not reference a step name, hence it applies to ALL PREVIOUS STEPS. If any step prior gets a non-zero return code, the execution of the step with COND=(0,NE) will be bypassed.

The system is doing exactly what you told it to do.


Hence my problem. I want the COND= to apply to all previous steps in the currently executing proc, not the previous executions of the proc earlier in the job. I apologize if I am not being clear about this.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7914
Location: Bellevue, IA

PostPosted: Fri Jan 07, 2011 2:28 am    Post subject:
Reply with quote

Unless you explicitly name each step of the proc by using the appropriate two-level identifier, what you want to to cannot be done. You might want to investigate using your site's job scheduler to schedule three separate jobs, in which case the only condition codes to matter will be the ones in the current job.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Jan 07, 2011 2:44 am    Post subject:
Reply with quote

Hello,

Quote:
I want the COND= to apply to all previous steps in the currently executing proc, not the previous executions of the proc earlier in the job. I apologize if I am not being clear about this.
What you want is clear. . . That you cannot have it the way you are trying to do it does not yet appear to be clear to you . . .

If you change the process to have 1 submit 2 then 2 submit 3, the problem goes away.

Or completely qualify which COND to check.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


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

PostPosted: Fri Jan 07, 2011 3:18 am    Post subject:
Reply with quote

Alex Garcia wrote:
Hence my problem. I want the COND= to apply to all previous steps in the currently executing proc, not the previous executions of the proc earlier in the job. I apologize if I am not being clear about this.

Akatsukami wrote:
Change the relational expression to ((STEP1.RC = 0) & (┬ČABEND)).
Back to top
View user's profile Send private message
Alex Garcia

New User


Joined: 06 Jan 2011
Posts: 9
Location: Kansas City

PostPosted: Fri Jan 07, 2011 3:27 am    Post subject:
Reply with quote

thanks to all for your input. We were trying to avoid creating 18 new jobs and the associated schedule changes to try and resolve this problem.

The fact that I cannot do this the way that I should be able to do it is very clear to me now. This is not the answer that I sought, but is still an answer to my question.

I appreciate your efforts
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts PL/I code tuning/Performance improvement Virendra Shambharkar PL/I & Assembler 4 Mon Dec 05, 2016 11:57 am
No new posts What is the code in CLIST to enable t... jackzhang75 CLIST & REXX 1 Fri Dec 02, 2016 3:02 am
No new posts IDEAL - Code Retrieval yugendran CA Products 0 Fri Nov 25, 2016 3:27 pm
No new posts DFHWS2LS return value divated CICS 4 Mon Nov 07, 2016 5:44 pm
This topic is locked: you cannot edit posts or make replies. Need to code a Rexx PGM sundaram.naveen CLIST & REXX 18 Thu Oct 06, 2016 6:45 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us