Decimal data is at the heart of most business applications. Floating point and binary
There are two forms of decimal data:
Zoned decimal data — Occupying 1 byte for every digit declared.
Packed decimal data — Occupying approximately 1 byte for every two digits declared.
The AS/400 is strict when it comes to valid decimal data. The predecessor of the AS/400, the System/38, had no mechanism to handle invalid decimal data. RPG programs written for System/38 had to completely control the handling of invalid decimal data messages or they
Because much of the data contained on the AS/400 has been "
Decimal data errors occur during program runtime when a packed or zoned decimal field contains data that is invalid. An example of invalid data can be a zoned decimal field containing blanks or the
The AS/400 RPG IV compiler provides an option to ignore decimal data errors. The CRTBNDRPG and CRTRPGMOD commands support the FIXNBR parameter as
{% if main.adsdop %}{% include 'adsenceinline.tpl' %}{% endif %}
FIXNBR(*NONE *ZONED *INPUTPACKED)
The default option, FIXNBR(*NONE), causes decimal data errors to generate an exception/error. In this situation, the default RPG exception/error handling routine is called when an error occurs. If the *PSSR subroutine is specified in the RPG program, that subroutine is called when the exception/error occurs. The default of FIXNBR(*NONE) is appropriate when processing AS/400 database files containing valid numeric data.
The FIXNBR(*ZONED) option causes decimal data errors within zoned decimal numeric fields to be corrected. This is performed by the underlying AS/400 system licensed internal code (SLIC). When an RPG program is run, the AS/400 system prefers to use packed decimal fields. This means that
binary fields
and
zoned fields
, declared within an RPG IV program, are internally mapped to packed decimal fields. Except when decimal data errors are
Using FIXNBR(*ZONED) causes the SLIC to test the zoned decimal fields during this translation. If the zoned decimal field contains all blanks, for example, the blanks are converted to zeros. This special case is the most common type of decimal data error. The process of fixing zoned decimal fields containing blanks is known as blank transparency .
In another situation, when a zoned decimal field contains non-numeric data, the SLIC ignores the top half of each byte (the zone ), except for the right-most byte. The right-most byte contains the sign of the number. If the sign is invalid, it is set to positive.
The bottom half of each byte (the
digit
) is
Typically, FIXNBR(*ZONED) is used in programs with zoned decimal input fields or data structures that contain numeric subfields.
Because data structures, by default, are
The FIXNBR(*INPUTPACKED) option causes decimal data errors within packed decimal input fields, read from the database, to be corrected. This is performed by the underlying AS/400 system licensed internal code (SLIC). When an RPG program is run and a record is read, the system checks packed input fields for invalid packed decimal data. If there is a decimal data error, the system sets the field's value to zero.