What is valid data

advertisement
What is valid data?
We have a programmer that experienced a problem on the z/OS host after testing in
Mainframe Express. It seems that Mainframe Express was placing Low Values in
Working Storage fields while animating, but the z/OS mainframe was using residual
values in working storage fields. Some of the fields in question had incorrect names
and such. So, the mainframe was abending because the fields were not initialized.
Is there a way to keep Mainframe Express from tracking storage values?
The underlying issue here is really dealing with the contents of storage items
containing valid data at the time they are being referenced by Procedure Division
code.
An explanation follows.
The DEFAULTBYTE directive in Mainframe Express should place Low Values into
Working Storage fields. And on the host IBM does this via an LE (Language
Environment) runtime option. IBM warns this takes a performance hit.
The best thing to do is use the INITIALIZE verb on any platform.
The INITIALIZE verb places Zeroes into numeric fields and Spaces into
alpha/alphanumeric fields. Since the INITIALIZE will work on multiple platforms
(z/OS, Windows, UNIX) it is the best solution.
The bulk of our data validation work has been for INT code since we expect
programmers to debug their user code with INT code and then use GNT code for
previously tested programs.
So our default for GNT code is to not check data values. However we are making
incremental changes to GNT code because of customer requests.
IBM has long documented that programs should validate data before using it.
See this strong statement from IBM in its VS Cobol II manual and a weaker one from
their z\OS Compiler.
Title: VS COBOL II Application Programming Guide
Document Number: SC26-4045-05
http://publibz.boulder.ibm.com/cgibin/bookmgr_OS390/BOOKS/IGYA1101/3.3.2?SHELF=IGYSH007&DT=19930312141
355
in section 3.3.2, Notice the last sentence of the second paragraph:
It is your responsibility to ensure that the contents of a data item
conform to its PICTURE and USAGE clauses before using
the data item in any further processing steps.
IBM has since toned down their previous statement for their latest compiler
but the intent remains the same:
Title: Enterprise Cobol for z/OS Programming Guide Version 3 Release 4
Document Number: SC27-1412-05
http://publibz.boulder.ibm.com/cgibin/bookmgr_OS390/BOOKS/IGY3PG30/1.3.7?SHELF=IGY3SH30&DT=20050628164
603
in section 1.3.7, notice the last sentence of the first paragraph:
The compiler assumes that values you supply for a data item are valid
for the PICTURE and USAGE clauses, and does not check their validity.
Ensure that the contents of a data item conform to its PICTURE
and USAGE clauses before using the data item in any further
processing steps.
Also, notice the last sentence of the second paragraph:
When you give an item a value that is incompatible with its data
description, references to that item in the PROCEDURE DIVISION are
undefined and your results are unpredictable.
IBM are saying that all data must be valid before using it, but it is contradictory
because their default numeric processing compiler option is NUMPROC(NOPFD),
which means they will perform sign validation processing trying to 'fix up' the user's
data. This was done for compatibility with the old IBM OS/VS Cobol compiler, but it
doesn't always work.
Enterprise Cobol for z/OS Programming Guide :
http://publibz.boulder.ibm.com/cgibin/bookmgr_OS390/BOOKS/IGY3PG32/2.4.35?SHELF=IGY3SH33&DT=2006111713
1343
in section 2.4.35, notice the reference to using an INITIALIZE verb and the
comments about each of the NUMPROC options.
In order to emulate IBM's default behavior Micro Focus uses this group of
directives:
NUMPROC(PFD) :
HOSTNUMMOVE HOSTNUMCOMPARE HOSTARITHMETIC
NOSIGNFIXUP CHECKNUM
NUMPROC(NOPFD):
HOSTNUMMOVE HOSTNUMCOMPARE HOSTARITHMETIC
SIGNFIXUP CHECKNUM
The first two are defaulted with a host dialect in Mainframe Express. The others must
be passed as Additional Directives.
Micro Focus believes that good code passes good data.
So we will stop a running program when the contents of a field are not conforming to
its PICTURE and USAGE definition. We have added many host emulation directives to
our compiler and made many runtime fixes in an effort to emulate IBM's elusive
behavior. We are close, but we will never achieve exact compatibility because they
do not document all their anomalies.
No one can guarantee when a S0C7 will happen on the host and when it will
not, so IBM has avoided such documentation.
This scenario involves the use of un-initialized storage.
IBM supplies a runtime switch to initialize storage via their LE common runtime for
Cobol, C, Fortran, and PL/I. The switch is named STORAGE. It is described in the
LE Programming Reference.
Title: z/OS V1R9.0 Language Environment Programming Reference
Document Number: SA22-7562-09
http://publibz.boulder.ibm.com/cgibin/bookmgr_OS390/BOOKS/CEEA3180/CCONTENTS?SHELF=CEE2BK80&DN=SA227562-09&DT=20070428023816
in section 1.2.57 STORAGE:
http://publibz.boulder.ibm.com/cgibin/bookmgr_OS390/BOOKS/CEEA3180/1.2.57?SHELF=CEE2BK80&DT=2007042802
3816
But also reference 1.2.57.4 to read what IBM says about performance with this
option. The defaults in Micro Focus for INT code and GNT code use the
DEFAULTBYTE(00) directive to set un-initialized storage to binary Zeroes (x'00'), but
like IBM's option, this doesn't mean that the data is now correct.
The best answer is to use an IF NUMERIC test prior to any arithmetic operations in
your programs.
More references for initializing variables in the Cobol program:
Initializing variables
VS Cobol II Programming Guide - section 3.4.5:
http://publibz.boulder.ibm.com/cgibin/bookmgr_OS390/BOOKS/IGYA1101/3.4.5?SHELF=IGYSH007&DT=19930312141
355
Initializing variables Enterprise Cobol for z\OS Programming Guide section 1.2.2 (a very nice table):
http://publibz.boulder.ibm.com/cgibin/bookmgr_OS390/BOOKS/IGY3PG30/1.2.2?SHELF=IGY3SH30&DT=20050628164
603
When we wrote the Micro Focus Compiler and Runtime, we followed IBM's rules
as set forth in their manuals, but the values passed by IBM's code do not
always match their documentation in practice.
Download