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?
This is because the code now generates ZAP instructions.
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.
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
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.
|Software Development||COBOL for VSE/ESA||Compile|
|Software Development||COBOL for OS/390 & VM||Compile||VM/ESA||2.1, 2.2|