Page 1 of 1

Can we initiate abend in a Job from cobol?

Posted: Fri Jul 19, 2013 12:00 pm
by Manoj
Hello,

It it possible to make a job abend from a cobol Program, for testing purpose?

Re: Can we initiate abend in a Job from cobol?

Posted: Fri Jul 19, 2013 4:30 pm
by Robert Sample
Yes, there are subprograms that can be called to invoke an abend. The specific program called depends upon the release of COBOL you are using on the mainframe -- Enterprise COBOL, for example, would CALL 'CEE3ABD' or CALL 'CEE3AB2' to abend (check the Language Environment Programming Reference manual in the Language Environment bookshelf for more information).

These will be USER abends, NOT SYSTEM abends. If you wanted your code to generate an S0C4 abend, for example, then you're out of luck -- other than getting the actual condition, I know of no way to manually generate system abends.

Re: Can we initiate abend in a Job from cobol?

Posted: Sat Jul 20, 2013 11:42 am
by Manoj
Thanks Robert.

I also thought about user abends, however one of senior is insisting on getting a system-abend and in vain. Possibly, I'll try using a table while will go beyond the table range - perhaps that will cause S0C4 but I'm not sure if it's good to test this way.

Re: Can we initiate abend in a Job from cobol?

Posted: Sat Jul 20, 2013 5:31 pm
by Robert Sample
If you need a system abend, something like this untested code should do it:

Code: Select all

01  WS-ABEND.
    05  WS-A1 PIC X(02) VALUE ',,'.
    05  WS-A2 REDEFINES WS-A1
              PIC S9(04) COMP-3.

*    CAUSE S0C7 ABEND
     ADD 1 TO WS-A2.

Re: Can we initiate abend in a Job from cobol?

Posted: Mon Jul 22, 2013 11:43 am
by Manoj
Hi Robert,

Thanks - this works and causes S0C7.

However, I'm thinking is it a good way of testing, to test/testify the application against abends? Please suggest.

Re: Can we initiate abend in a Job from cobol?

Posted: Tue Jul 23, 2013 12:32 am
by Anuj Dhawan
If you are doing this just to test your code against some "test-conditions", I'd say - user abends are best suited. Creating a "system test" would testify what - possibly nothing.

Sticking to user-abends for your testing sounds a perfect idea compared to a system-abend, also not necessarily in Prod you get the same abend for exact same reaosn -- notice I said "same" not even "similar" -- and that can change the entire game.

Re: Can we initiate abend in a Job from cobol?

Posted: Tue Jul 23, 2013 12:36 am
by Robert Sample
I think one thing you need to be very aware of is that there really is no way to test for all potential abends. There are thousands of potential abends, many of which only occur under very selective circumstances that may never apply to your code, and others occur based on external factors (example: Sx37 abends -- SB37, SD37, SE37 -- are abends that are caused by lack of disk space; you may never get one but if your application writes disk data sets then they are, potentially, abends you could see. Also, some sites install a third-party product called STOPX37 that prevents these abends). IBM devotes TEN manuals (each probably well over 1000 pages) to error codes and their explanations in the MVS bookshelf for z/OS, which should give you an idea as to the potential number of abends that a mainframe system could experience.

However, there are not that many common abends for applications: S001, S013, S0C1, S0C4, S0C7, S222, S522, S806, S878, S913, SB37/SD37/SE37 are probably the most common. Learning what each is (and how to fix them) will resolve a great number of your future problems.

Also, you (hopefully) are aware that z/OS distinguishes between an ABEND and a non-zero return code. For example, an FTP job may give a non-zero return code that could indicate a problem with the other side of the FTP, or a non-zero return code that means things went okay, or a zero return code.

Re: Can we initiate abend in a Job from cobol?

Posted: Wed Jul 24, 2013 1:20 pm
by Manoj
Thanks Robert, that's a great explanation.

Yes, I understadn the difference between an abend and a non-zero return code... :)