View previous topic :: View next topic
|
Author |
Message |
shreevamsi
Active User
Joined: 23 Feb 2006 Posts: 305 Location: Hyderabad,India
|
|
|
|
Hi,
Could anybody help me know how to set the return code for a succesful execution of a Natural Batch program so that i can handle the return code in the subcequent steps in JCL.
Thanks,
~Vamsi |
|
Back to top |
|
|
shreevamsi
Active User
Joined: 23 Feb 2006 Posts: 305 Location: Hyderabad,India
|
|
|
|
Hi,
I understand from the previous post that there are no special registers, like in Cobol where we can set the retrun code for a Natrual Batch programs.
Thanks,
~Vamsi |
|
Back to top |
|
|
Catherine Gutowski
New User
Joined: 02 Oct 2008 Posts: 1 Location: Dallas, TX
|
|
|
|
I realize this is a really old post, but the info is not correct so I wanted to make sure the next person using google to find this info got the right answer.
In a batch Natural program, you can use TERMINATE 33 to send a return code 33 to the JCL. I believe it will stop execution of your Natural program at that point (acting like an ESCAPE IMMEDIATE function), but if you define the JCL to accept 33 as a return code, it will allow the remaining jobsteps to continue processing.
Here is sample code:
/* IF NO DATA THEN STOP THE PROGRAM
IF #COUNT-GOODREC EQ 0
TERMINATE 33
END-IF
We use this to run a batch job everyday, look for records, and if none found, then stop the program with 33. The JCL for the email notice then evaluates the COND code of the natural step and if it is 33 it doesn't execute the step to send the email notification. We only want to be notified if there are records.
Not sure why 33 is the chosen number, but it works. If I recall correctly, it didn't work with other numbers, but it's been a long time and I dont' remember. Note that you will have to set your job up to allow 33 as a valid return code, and in our shop that meant that our normal abend codes of 4, 8 and 12 became invalid as abend codes, since we had to state that 33 was the highest valid return code. In our case, this was only a report so it was not mission critical if it really abended, and of course we programmed it so well that we handled all possible bad data conditions in the program without causing an abend :-)
Your shop may be different and may allow specific codes to be defined.
Also - there is another way to abend a natural program, either online or batch: MOVE 9974 to *ERROR-NR
or you can use the old tried and true divide by 0. Both of these will cause an abend of the step in the batch job, which may not allow you to continue processing your steps. Not sure which error code they return. |
|
Back to top |
|
|
helga
New User
Joined: 11 Sep 2006 Posts: 23
|
|
|
|
Quote: |
you can use the old tried and true divide by 0 |
not always . . . |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
ok, I'll bite. How come? |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
Because you might customize Natural to trap an abend and produce an RC for it. Don't forget that you are not invoking a Natural program, but the Natural Nucleus.
O. |
|
Back to top |
|
|
|