Skip to content

Commit 994c4bf

Browse files
authored
Merge pull request #335 from oathar/lab3
Add new lab: Handling S0CB ABEND (Division by Zero)
2 parents f7796de + d660d52 commit 994c4bf

File tree

7 files changed

+68
-4
lines changed

7 files changed

+68
-4
lines changed

COBOL Programming Course #2 - Learning COBOL/COBOL Programming Course #2 - Learning COBOL.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2823,9 +2823,8 @@ All files are available in your VS Code Zowe Explorer.
28232823
### Instructions
28242824

28252825
1. Open `CBL006A.cobol` from your VS Code Zowe Explorer.
2826-
28272826
This program reads account records and counts how many clients are from `"New York"`.
2828-
2827+
28292828
2. Submit the JCL job `CBL006AJ.jcl`. View the job output from the JOBS section.
28302829
- Confirm that no syntax or runtime errors occurred.
28312830
- Now carefully read the final line of the report. `New York Clients = 000`
@@ -2850,7 +2849,7 @@ Ask yourself: *Is this the number of New York clients you expected?*
28502849

28512850
This chapter aims to introduce the concept of implementing arithmetic expressions in COBOL programs. We will review the basic concept of arithmetic expressions, operators, statements, limitations, statement operands, as well as precedence of operation within the expressions. You will be able to follow along with a comprehensive example exhibiting the usage of arithmetic expressions in a COBOL program that you have seen in previous chapters and labs. Following the chapter is a lab to practice the implementation of what you have learned.
28522851

2853-
2852+
28542853

28552854
- **What is an arithmetic expression?**
28562855

@@ -3602,6 +3601,39 @@ CPU attempted to divide a number with 0.
36023601
- Incorrectly initialized or uninitialized variables
36033602
- Missing or incorrect data edits
36043603

3604+
## Lab
3605+
3606+
**Handling ABEND S0CB - Division by Zero**
3607+
3608+
**Objective:** Learn how to recognize and debug a common ABEND error, S0CB caused by attempting to divide by zero in a COBOL program.
3609+
3610+
In COBOL, a division by zero will not result in a warning, it will immediately cause a system ABEND with code S0CB. This kind of error may compile successfully and even run, but will crash at runtime with messages like:
3611+
3612+
*`CEE3211S The system detected a decimal-divide exception (System Completion Code=0CB)
3613+
`*
3614+
3615+
### Instructions
3616+
1. Open the file `CBL0013.cobol`. Look at the line where division occurs:
3617+
3618+
![](Images/image0068.png)
3619+
3620+
2. In `CBL0013.cobol`, notice that DENOMINATOR is initialized to 0, causing a division-by-zero.
3621+
3622+
3. Submit the JCL program: `CBL0013J.jcl`.
3623+
3624+
*You should observe the job fails with a S0CB ABEND.*
3625+
3626+
![](Images/image0067.png)
3627+
3628+
4. Fix the error by modifying DENOMINATOR to a non-zero value like:
3629+
3630+
`01 DENOMINATOR PIC 9(04) VALUE 10.
3631+
`
3632+
3633+
5. Save and resubmit the JCL. The program should now complete successfully and display:
3634+
3635+
![](Images/image0069.png)
3636+
36053637
### S222/S322 - Time Out / Job Cancelled
36063638

36073639
When you submit a JCL, it is possible to determine how much time you want to allocate to a job. If the job surpasses that allocated time, it will time out. Depending on how your system is set up, a job that has taken a prolonged time may be canceled either manually by the operator or automatically.
66.5 KB
Loading
36 KB
Loading
22.2 KB
Loading
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
IDENTIFICATION DIVISION.
2+
PROGRAM-ID. CBL0013.
3+
AUTHOR. Athar Ramzan.
4+
5+
DATA DIVISION.
6+
WORKING-STORAGE SECTION.
7+
01 NUMERATOR PIC 9(04) VALUE 1000.
8+
01 DENOMINATOR PIC 9(04) VALUE 0.
9+
01 RESULT PIC 9(04).
10+
11+
PROCEDURE DIVISION.
12+
MAIN-PROCEDURE.
13+
DISPLAY "Starting Division".
14+
DIVIDE NUMERATOR BY DENOMINATOR GIVING RESULT.
15+
DISPLAY "Result is: " RESULT.
16+
STOP RUN.

COBOL Programming Course #2 - Learning COBOL/Labs/cbl/CBL006A.cobol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
IDENTIFICATION DIVISION.
33
*-----------------------
44
PROGRAM-ID. CBL006A
5-
AUTHOR. Otto B. Boolean.
5+
AUTHOR. Athar Ramzan
66
*--------------------
77
ENVIRONMENT DIVISION.
88
*--------------------
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//CBL0013J JOB 1,NOTIFY=&SYSUID
2+
//***************************************************/
3+
//COBRUN EXEC IGYWCL
4+
//COBOL.SYSIN DD DSN=&SYSUID..CBL(CBL0013),DISP=SHR
5+
//LKED.SYSLMOD DD DSN=&SYSUID..LOAD(CBL0013),DISP=SHR
6+
//***************************************************/
7+
// IF RC = 0 THEN
8+
//***************************************************/
9+
//RUN EXEC PGM=CBL0013
10+
//STEPLIB DD DSN=&SYSUID..LOAD,DISP=SHR
11+
//SYSOUT DD SYSOUT=*,OUTLIM=15000
12+
//CEEDUMP DD SYSOUT=*
13+
//SYSUDUMP DD SYSOUT=*
14+
//***************************************************/
15+
// ELSE
16+
// ENDIF

0 commit comments

Comments
 (0)