IBM Enterprise COBOL
01 A PIC 9 VALUE ZERO.
ADD 1 TO A
Here's a short program. It obviously does nothing but add one to the field A.
However, toss it into the compiler, and... http://www-01.ibm.com/support/docview.wss?uid=swg21156178
You can generate a complete listing of compiler diagnostic messages with their >message numbers, severities, and text by compiling
a program that has program-name ERRMSG.
You can code just the PROGRAM-ID paragraph, as shown below, and omit the rest >of the program.
The key is to have
errmsg as the
PROGRAM-ID. No other code is required. The code in my example is just to convince that it is a real program which produces no output.
This is the example IBM show in the link:
Indeed, this is enough:
The quick brown fox jumped over the
lazy dog, or any other text you like.
This is an example of the output: http://www-01.ibm.com/support/docview.wss?uid=swg21156178&aid=1
When the compiler gets to errmsg. (note the full-stop/period, which doesn't have to be immediately after errmsg, but must exist after it somewhere in the source) it knows what is needed, reads to the end of the source and then produces the listing, including the description of the format and information contained in the error messages, and all the messages themselves.
As a curiosity, you can try this:
This time no full-stop/period is encountered before the end of the source is reached, and a (very) minor compiler bug is revealed, as the compiler continues reading, and abends (ends abnormally, crashes) with an S001 Reason Code 5 and
IEC020I GET ISSUED AFTER END-OF-FILE
No IBM Mainframe COBOL has ever separately documented its error messages in an actual manual.