Is it possible to abend your job intentionally through COBOL program.
suppose I have an Input file having Header,Detail and Trailer records. I will write a COBOL pgm which reads this file.If no Detail records are found in this file then I want to abend my job by giving some Abend Message and some Abend Code.Is it Possible?
Is it possible to abend your job intentionally through COBOL program. suppose I have
Share
Do you want to ABEND your program or just set a RETURN-CODE?
I suspect setting a RETURN-CODE, writing a message
and then terminating the program via a
STOP RUNorGOBACKis all thatyou really want to do. Causing an actual ABEND may not be necessary.
In an IBM batch environment, the RETURN-CODE set by your program becomes the
RC for the JCL job step the program was run under. This is typically what you
want to set and test for.
The
RETURN-CODEis set byMOVEing a numeric value to it. For example:You may also issue a program dump from a program run under Language Environment (IBM
Mainframe option) using
the CEE3DMP–Generate dump
utility.
In older IBM Mainframe COBOL programs, you might see calls to the
ILBOABN0routine. This callabended your program and issued a dump. This routine is now depreciated in favour of the
technique outlined above.
Finally, really old programs might have code in them to generate abends. This can be done in any number of ways, but division by zero was
often a favourite:
Works every time!
Personally, I recommend setting the
RETURN-CODEover callingILBOABN0or data-exception tehcniques.Note: The RETURN-CODE special-register is not part of the COBOL-85 standard. It is available as an IBM extention to the language. You may need to resort to a different mechanism if you are working in a non-IBM compatible environment.