Quasar wrote:The Program is Killed - ABEND
When a Program encounters an exceptional situation(error), which it is unable to handle, the OS has to intervene and KILL the Program. This is called an Abend. When an Abend occurs, the MVS OS is in a hurry to rush to the Abend-Exit door, and flushes out all "the remaining steps" in the Job. Every ABEND has ABEND Code.
I can't really agree with this. The program is not "encountering" an error it is "unable to handle". In Cobol, for definite, you have no way at all of "handling" or "trapping" an Abend. An Abend, by which I mean a System Abend, a four character message starting with S and having three hex-digits following, is when your program, through an error, attempts an instruction, at machine code level, that it is impossible to carry out. It is illogical in this case for anything other than program code constituting an Abend-exit and the sort of clean-up that Steve has already mentioned.
Quasar wrote:The Program terminates peacefully -
When a Program encounters an exception, which it was designed to detect and handle, it comes to an end peacefully, by executing STOP RUN. The Software Program complains about this error(exception) by setting a two-digit status code, called COND CODE or RETURN Code. Programs set different Return-codes, to indicate different things to the Outside-world, and raise an alarm. Such programs are said to be robust.
As Dick has pointed out, you don't mention User Abends at all. I assume here you are talking about "errors" from the original question. To me, the vast majority of "errors" in a program are those that the program gives no indication of. If you do a calculation where you are supposed to multiply by two, but instead, in error, you divide by two, nothing is going to do anything about setting a return code or anything remotely similar. The program will proceed quietly to the end (assuming no further errors which cause an Abend or setting of your return code...) and will complete, with the incorrect value stitting on your report/screen or having corrupted your output file/database.
A Cobol program, even a main program, doesn't have to use a STOP RUN. On the MVS/OS side of things anyway, it can use the RETURN/GOBACK just like a sub-program, because it has, for your purposes, been "called" by the operating system.