Can we initiate abend in a Job from cobol?

OS/VS COBOL, COBOL II, Enterprise COBOL for z/OS. OpenCOBOL and OOCobol.
Post Reply
Manoj
Registered Member
Posts: 33
Joined: Wed Jul 17, 2013 9:10 am

Can we initiate abend in a Job from cobol?

Post by Manoj »

Hello,

It it possible to make a job abend from a cobol Program, for testing purpose?
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1888
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

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

Post 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.
Manoj
Registered Member
Posts: 33
Joined: Wed Jul 17, 2013 9:10 am

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

Post 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.
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1888
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

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

Post 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.
Manoj
Registered Member
Posts: 33
Joined: Wed Jul 17, 2013 9:10 am

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

Post 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.
User avatar
Anuj Dhawan
Founder
Posts: 2801
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Contact:
India

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

Post 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.
Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1888
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

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

Post 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.
Manoj
Registered Member
Posts: 33
Joined: Wed Jul 17, 2013 9:10 am

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

Post by Manoj »

Thanks Robert, that's a great explanation.

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

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM COBOL, GnuCOBOL (OpenCOBOL), OOCobol.”