Data Exception (ABEND0C7) on Numeric MOVE using Enterprise COBOL for zOS.

Technote (FAQ)


Question

Why would programs that ran successfully under OS/VS COBOL receive a Data Exception on a MOVE of a field defined as numeric which does not contain valid numeric data when recompiled under Enterprise COBOL for z/OS, COBOL/OS390 and VM or COBOL/VSE?

Cause

This is because the code now generates ZAP instructions.

Answer

This can occur when non-numeric data is input to numeric fields.
You will need to do a validity check of data input to numeric fields to ensure it is numeric if this is a possibility.
*
ADDITIONAL INFORMATION:
The customer's COBOL program failed with a DATA EXCEPTION when compiled using COBOL II or later. When compiled with OS/VS COBOL, it ran successfully.
The failing PSW was pointing to a Zero and Add (ZAP) instruction in the compiled code of his program which was generated by a MOVE statement within the program. The data being moved should have been numeric, but instead contained blanks (x'40404040') as read from a file. The new COBOL code generated for the failing COBOL MOVE statement included the ZAP instruction which produced the ABEND0C7. The OS/VS COBOL code generated for the COBOL MOVE statement did not include a ZAP instruction or any other code that would result in a DATA EXCEPTION.
This means that the user will need to code validity checks if data read from a file may not always contain numeric characters for fields defines as numeric.
It is dangerous to write COBOL code that depends on internal representation by the hardware. The COBOL language requires that numeric fields contain numbers and nothing else. It's a quirk of the z/Series hardware that dates back 40 years to the old IBM/360 machines that you can get away with having leading blanks in a numeric field. It was never documented for COBOL.
01 MY-DATA PICTURE 9(5).
IF MY-DATA IS NOT NUMERIC
INSPECT MY-DATA REPLACING ALL SPACES BY ZEROS
IF MY-DATA IS NOT NUMERIC DISPLAY 'ERROR' STOP RUN
END-IF
END-IF.
There is also an intrinsic function called FUNCTION NUMVAL that will try to convert MY-DATA to a number.

An ABEND0C7 can also occur if one tries to do arithmetic on a packed decimal (COMP-3) field that contains EBCDIC data because there is not valid packed sign information.
For example suppose 77 MY-DATAP PIC S9(9)V99 contains X'F0F0F0F0F0F0' instead of a packed number.

Cross Reference information
Segment Product Component Platform Version Edition
Software Development COBOL for VSE/ESA Compile
Software Development COBOL for OS/390 & VM Compile VM/ESA 2.1, 2.2

Historical Number

RTA000133643

Rate this page:

(0 users)Average rating

Document information


More support for:

Enterprise COBOL for z/OS
Compile

Software version:

3.4, 4.1, 4.2

Operating system(s):

z/OS

Reference #:

1005546

Modified date:

2009-12-14

Translate my page

Machine Translation

Content navigation