Skip to main content

Problem:

Is there a compiler directive or other external way to initialize data items without acutally changing the code in the program or copybook?

Resolution:

If a program does not explicityly initialize numeric fields the default is spaces.  To be sure of having correct numeric values  code the value clause in working storage or use the Procedure Division command INITIALIZE ( See the COBOL reference).

The compiler directive -C SPZERO can be specified to change all spaces in numeric fields to zeroes

Here is another directive that might be useful: See the Server Express Compiler Directives Reference:

http://supportline.microfocus.com/Documentation/books/sx50/sx50indx.htm

DEFAULTBYTE

Initializes each otherwise undefined byte of the Working-Storage Section to the character given.

Syntax:

>>-.---.--DEFAULTBYTE--"integer"-----------><

    -/-

Parameters:

integer ASCII code of the character, in decimal.

Properties:

Default: DEFAULTBYTE"32" (Dialect  )

Phase: Syntax check

$SET: Initial

Dependencies:

Set to DEFAULTBYTE"32" immediately by CHARSET"ASCII".

Set to DEFAULTBYTE"00" immediately by CHARSET"EBCDIC", DIALECT"SAA1", DIALECT"SAA2", DIALECT"OSVS", DIALECT"DOSVS", DIALECT"VSC2", DIALECT"COBOL37[012]", DIALECT"BS2000", DIALECT"SNI", MS, IBM-MS or PC1.

Comments:

integer is a decimal value. For example, if you want to specify an EBCDIC space use DEFAULTBYTE"64"; to specify an ASCII space use DEFAULTBYTE"32".

**************

Note: Be careful setting DEFAULTBYTE"00"  <-- Binary zeros

As this could cause  non-numeric errors on signed decimal fields.

Old KB# 2300