Divide By Zero Error Encountered In Cobol
Contents |
in ILE/COBOL... From: "Michael Rosinger"
Divide By Zero Error Encountered Ssrs
some of you are unaware of this behavior in ILE/COBOL. We are in the midst of migrating several
Tsql Divide By Zero Error Encountered
hundred COBOL programs from a VSE mainframe environment to ILE/COBOL on v5r3/v5r4 systems. VSE supports a language environment (LE) similar to ILE but not nearly as robust. We have many programs https://www.ibm.com/support/knowledgecenter/SSLTBW_1.13.0/com.ibm.zos.r13.ceea200/uchcbl.htm that contain arithmetic statements that, depending on the data passed, could potentially encounter division by zero. Practically all of these programs are not coded with the ON SIZE ERROR clause that would trap that exception. When division by zero does occur in the LE environment and no exception handler is specified, the O/S gets involved, cancels the program and produces a http://archive.midrange.com/midrange-l/200710/msg00033.html dump. This is the default behavior when division by zero occurs and it is not handled by the application program. I was shocked to discover that in ILE/COBOL this is not the case at all. If division by zero is encountered at run-time and no exception handler is specified (i.e. no ON SIZE ERROR clause) ILE/COBOL executes an implicit "MOVE ZERO TO result-field" and continues normal processing with the next statement. I have confirmed this with IBM and have an open PMR on this issue. For us that is a serious problem. While I agree completely that the programs should have been written such that the program would handle the exception, they weren't and it was acceptable to us that the O/S would trap the problem. Now we have a very serious problem with our migration. The IBM solution is suppressing the problem which, when encountered, will cause other problems that may not be apparent until a later time. By the way, it is my understanding from conversations with others that ILE/RPG does NOT have the same default behavior that ILE/COBOL does
GnuCOBOL (formerly OpenCOBOL) A free COBOL compiler Brought to you by: bgiroud, btiffin, knishida, sf-mensch, simrw Summary Files Reviews Support Discussion Wiki Mailing Lists Code (GNU/OC 1.1, 1.1CE, 2.x, C++) Tickets â–¾ Wish List Patches Bugs News FAQ and How-To https://sourceforge.net/p/open-cobol/bugs/44/ Manuals and Guides Contributions (Tools/Samples incl. Games) CVS-History (Old OC-versions 0.3 to 1.0) Create http://www.jaymoseley.com/hercules/sabends.htm Ticket View Stats Group 2.0 unclassified invalid reportwriter GC++ 2.0 GC 1.x Programmer's Guide GC 2.1 Searches Changes Closed Tickets Current ToDo Help Formatting Help #44 cobc 1.1: anything divided by zero... no crash ? Milestone: invalid Status: wont-fix Owner: nobody Labels: None Priority: 1 Updated: 2014-07-29 Created: 2012-10-28 Creator: acleve Private: No Hello, i am surprised, divide by that cobc 1.1 survives a div by zero. Even a statement compute ergebnis = 7/0 keeps the program running. Is this a bug or a feature ? My code and the result is the following: cobc (OpenCOBOL) 1.1.0 Copyright (C) 2001-2009 Keisuke Nishida / Roger While Built Aug 12 2012 14:25:24 Packaged Feb 06 2009 10:30:55 CET identification division. program-id. divbyzero. data division. working-storage section. 01 zaehler pic 9(2) value 25. divide by zero 01 nenner pic s9(2) value 10. 01 ergebnis pic 9(02) value zero. procedure division. a000-steuer section. display "Countdown.. to crash" move 10 to nenner perform with test after until nenner = -5 display "Nenner: " nenner compute ergebnis = zaehler / nenner display " --> " ergebnis compute nenner = nenner - 1 end-perform display "nanu ?" continue. end-a000-steuer. goback. The output was: Countdown.. to crash Nenner: +10 --> 02 Nenner: +09 --> 02 Nenner: +08 --> 03 Nenner: +07 --> 03 Nenner: +06 --> 04 Nenner: +05 --> 05 Nenner: +04 --> 06 Nenner: +03 --> 08 Nenner: +02 --> 12 Nenner: +01 --> 25 Nenner: +00 --> 25 Nenner: -01 --> 25 Nenner: -02 --> 12 Nenner: -03 --> 08 Nenner: -04 --> 06 nanu ? bye Alfred Related Discussion: For Simon, on bug tracker Discussion Brian Tiffin - 2012-10-29 Yep. To get divide by zero exception use DIVIDE zaehler BY nenner GIVING ergebnis ON SIZE ERROR DISPLAY "Error handler here" END-DISPLAY NOT ON SIZE ERROR DISPLAY "Success imperative here" END-DISPLAY END-DIVIDE It's COBOL standard not to error out on math, it's the programmers job to explicitly handle illegal computations. Freaked me out the first time too. ;-) See http://opencobol.add1tocobol.com/#what-stock-call-library-does-opencobol-offer and scroll down to 4.5.1 for a CBL_ERROR_PROC
second column contains a reason code. The third column contains the text explaining why the Abend may have occurred. If you would prefer to download this information as an Adobe® Portable Document File, use this link: http://www.jaymoseley.com/hercules/downloads/pdf/sabends.pdf. S001 - AN INPUT/OUTPUT ERROR CONDITION WAS ENCOUNTERED DURING EXECUTION OF A CHECK/GET/PUT MACRO INSTRUCTION. EITHER NO SYNAD ROUTINE WAS PROVIDED TO HANDLE THE ERROR, OR DCB=EROPT=ABE WAS SPECIFIED OR DEFAULTED. ***IF THE REGISTER 15 RETURN CODE IS AVAILABLE, SUPPLY IT IN THE*** ***S001 OPERAND FOR MORE SPECIFIC INFORMATION: H ABEND O(S001-RC)** --POSSIBLE CAUSE-- INPUT RECORD DESCRIBED INCORRECTLY, LENGTH ERROR TRIED TO READ AFTER ENCOUNTERING END OF FILE RECFM V IS INCOMPATIBLE WITH TRTCH ET TRIED TO WRITE ON AN INPUT FILE READ INTO A TABLE WHOSE SUBSCRIPT WAS ZERO INCORRECT LABEL PARAMETER TRTCH PARM WAS WRONG TAPE BEING READ IN WRONG DENSITY DIRECTORY OF PDS WAS OVERWRITTEN NSL LABEL HAD INCORRECT DSNAME, OPERATOR CANCELLED TRUE I/O FAILURE, UCB SHOW REDUNDANCY HARDWARE ERROR - BAD TAPE OR TAPE DRIVE SECONDARY SPACE ALLOCATION FOR DASD OUTPUT FILE TOO SMALL (SEE SB37) COBOL - INCORRECT USE OF BLOCK CONTAINS CLAUSE - HAD RECORDING MODE F WHEN GENERATED, BUT NOT WHEN READ S001 - 01 - AN I/O ERROR OCCURRED DURING BDAM CREATE, BSAM, BISAM, QSAM, OR BDAM AND NO SYNAD EXIT WAS SPECIFIED BY THE USER. S001 - 02 - AN ERROR WAS ENCOUNTERED WHILE ATTEMPTING TO CLOSE THE DATASET. S001 - 03 - FOR QSAM, AN ERROR WAS ENCOUNTERED THAT COULD NOT BE ACCEPTED. S001 - 04 - FOR QSAM, ABE OR AN INVALID VALUE FOR EROPT PARAMETER IN THE DCB AND/OR NO ERROR HANDLING (SYNAD) EXIT WAS SPECIFIED. S001 - 05 - FOR QSAM, A GET WAS ISSUED AFTER END-OF-FILE. S002 - RECORD IS GREATER THAN 32,768 BYTES, EXCEEDS MAXIMUM TRACK LENGTH OR STATED BLOCKSIZE, C