<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.webhuis.nl:443/index.php?action=history&amp;feed=atom&amp;title=COBOL_Std_7_Error_Handling</id>
	<title>COBOL Std 7 Error Handling - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.webhuis.nl:443/index.php?action=history&amp;feed=atom&amp;title=COBOL_Std_7_Error_Handling"/>
	<link rel="alternate" type="text/html" href="https://wiki.webhuis.nl:443/index.php?title=COBOL_Std_7_Error_Handling&amp;action=history"/>
	<updated>2026-09-11T08:01:26Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.17</generator>
	<entry>
		<id>https://wiki.webhuis.nl:443/index.php?title=COBOL_Std_7_Error_Handling&amp;diff=4724&amp;oldid=prev</id>
		<title>Martin: Created page with &quot;== 7. Error Handling ==  === 7.1 Return-Code Standard ===  All programs and DAL interfaces use the following result-code scheme via &lt;code&gt;DAL-RESULT&lt;/code&gt; / &lt;code&gt;SESSION-RESULT&lt;/code&gt; / &lt;code&gt;UI-RESULT&lt;/code&gt;:  {| class=&quot;wikitable&quot; style=&quot;width:100%&quot; ! Code !! Meaning !! Required Action |- | &lt;code&gt;0&lt;/code&gt; || Success || Continue processing. |- | &lt;code&gt;1&lt;/code&gt; || Error — recoverable || Log message; set result; return to caller for decision. |- | &lt;code&gt;2&lt;/code&gt; || End...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.webhuis.nl:443/index.php?title=COBOL_Std_7_Error_Handling&amp;diff=4724&amp;oldid=prev"/>
		<updated>2026-03-25T11:16:30Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;== 7. Error Handling ==  === 7.1 Return-Code Standard ===  All programs and DAL interfaces use the following result-code scheme via &amp;lt;code&amp;gt;DAL-RESULT&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;SESSION-RESULT&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;UI-RESULT&amp;lt;/code&amp;gt;:  {| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width:100%&amp;quot; ! Code !! Meaning !! Required Action |- | &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt; || Success || Continue processing. |- | &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; || Error — recoverable || Log message; set result; return to caller for decision. |- | &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt; || End...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== 7. Error Handling ==&lt;br /&gt;
&lt;br /&gt;
=== 7.1 Return-Code Standard ===&lt;br /&gt;
&lt;br /&gt;
All programs and DAL interfaces use the following result-code scheme via &amp;lt;code&amp;gt;DAL-RESULT&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;SESSION-RESULT&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;UI-RESULT&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width:100%&amp;quot;&lt;br /&gt;
! Code !! Meaning !! Required Action&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt; || Success || Continue processing.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; || Error — recoverable || Log message; set result; return to caller for decision.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt; || End-of-data / not found || Handle gracefully; this is not an error condition.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;3&amp;lt;/code&amp;gt; || Warning — processing continued || Log warning; continue.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;8&amp;lt;/code&amp;gt; || Fatal error — terminate || Log; disconnect DB; PERFORM Z000-PROGRAM-END.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;16&amp;lt;/code&amp;gt; || System error — abend || Emergency disconnect; STOP RUN with non-zero RETURN-CODE.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Note&amp;#039;&amp;#039;&amp;#039; — the pgcobol project uses only codes 0, 1, and 9/99 (EOF). Adopting the full scheme above provides finer-grained diagnostics and removes the ambiguity between &amp;#039;&amp;#039;error&amp;#039;&amp;#039; and &amp;#039;&amp;#039;end-of-data&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
=== 7.2 Mandatory Error Paragraph — E000-HANDLE-ERROR ===&lt;br /&gt;
&lt;br /&gt;
Every program must implement an &amp;lt;code&amp;gt;E000-HANDLE-ERROR&amp;lt;/code&amp;gt; paragraph:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cobol&amp;quot;&amp;gt;&lt;br /&gt;
       E000-HANDLE-ERROR.&lt;br /&gt;
           MOVE &amp;#039;E000-HANDLE-ERROR&amp;#039; TO ERR-PARAGRAPH&lt;br /&gt;
           MOVE ERR-MESSAGE         TO UI-SCREEN-MESSAGE&lt;br /&gt;
           MOVE &amp;#039;log-message&amp;#039;       TO UI-METHODS&lt;br /&gt;
           CALL &amp;#039;programui&amp;#039;         USING PROGRAM-UI&lt;br /&gt;
           IF ERR-SEVERITY &amp;gt; 4&lt;br /&gt;
               PERFORM Z000-PROGRAM-END&lt;br /&gt;
           END-IF.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 7.3 Prohibited Patterns ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width:100%&amp;quot;&lt;br /&gt;
! Prohibited Pattern !! Reason / Compliant Alternative&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;STOP RUN&amp;lt;/code&amp;gt; without DB disconnect || Leaves open transactions; always PERFORM Z000-PROGRAM-END first.&lt;br /&gt;
|-&lt;br /&gt;
| Ignoring SQLCODE after any EXEC SQL || Silent failures corrupt data; always EVALUATE SQLCODE.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;NEXT SENTENCE&amp;lt;/code&amp;gt; (post-COBOL 85) || Ambiguous scope; use CONTINUE inside a scoped IF / EVALUATE.&lt;br /&gt;
|-&lt;br /&gt;
| Empty WHEN OTHER with no comment || Add at minimum: &amp;lt;code&amp;gt;*-- no action required because &amp;amp;lt;reason&amp;amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;GO TO&amp;lt;/code&amp;gt; (except structured exit) || Use PERFORM, EVALUATE, EXIT PARAGRAPH, EXIT PROGRAM.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ALTER&amp;lt;/code&amp;gt; statement || Prohibited entirely; dynamic paragraph modification is untestable.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;SELECT *&amp;lt;/code&amp;gt; in EXEC SQL || Always name columns; column-order changes silently break host-variable binding.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== 7.4 Cleanup Always Attempted ===&lt;br /&gt;
&lt;br /&gt;
Termination paragraphs (Z000-series) must always be performed before program exit, regardless of whether prior steps succeeded. This guarantees that database connections and print files are always closed. Guard with conditional logic inside Z000 rather than skipping Z000 itself.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&amp;#039;&amp;#039;[[Cobol programming standards|← Back to index]]&amp;#039;&amp;#039;&lt;/div&gt;</summary>
		<author><name>Martin</name></author>
	</entry>
</feed>