Problem:
When migrating applications from a mainframe to the Windows platform, using Net Express, or a UNIX/Linux platform, using Server Express, platform specific issues can be encountered. One specific area that can be troublesome is when dealing with Packed Decimal data. This article discusses the issues of Packed Decimal data and how they can be dealt with.
When migrating an application that has been compiled on the mainframe with the NUMPROC(NOPFD) directive, the behaviour expected is that when comparing x'000c' with ZERO, they should be equal.
For example, the following program:
working-storage section.
01 a pic x(3) value x'00000c'.
01 b redefines a pic 9(5) comp-3.
procedure division.
if b=zero
then display ' a equal zero'
else display ' a not equal zero'.
stop run.
would be expected to display 'a equal zero'. But you may find that it displays 'a not equal zero' instead.
Resolution:
The answer is that compiling with HOSTNUMMOVE, HOSTNUMCOMPARE and SIGNFIXUP should resolve the problem. However, SIGNFIXUP is currently supported in intermediate code only and is only available on Mainframe Express v2.5 & v3.0, Net Express 4.0, and the forthcoming Server Express 4.0 SP2. There has been some of the initial SIGNFIXUP support in Server Express since version 2.2.
The explanation to this as follows:
The successful test for zero will only occur on the mainframe if the program has been compiled with the NUMPROC(NOPFD) directive. This directive causes the compiler to, amongst other things, fix up invalid sign nibbles for numeric display and comp-3 items before performing compares, moves, and arithmetic operations. The directive is intended for use in applications that cannot guarantee valid numeric data item contents during their operation and so leads to non-optimal code being generated.
For applications that can guarantee valid numeric data item contents, the NUMPROC(PFD) directive is more appropriate. No fixing up of invalid sign nibbles is performed. Compares and moves are performed as multi-byte operations wherever possible, eliminating the need for intermediate conversions of numeric data items.
In this particular example, when compiled with the directive NUMPROC(NOPFD) on the mainframe, the operator OR is applied to the sign nibble unsigned comp-3 item value with the value 0x0F before comparing with the unsigned comp-3 literal 0 (value 0x00000F) resulting in equality.
When compiled with the directive NUMPROC(PFD) instead, no fix up of the sign nibble of the comp-3 item value is performed, resulting in 0x00000C being compared with 0x00000F resulting in inequality.
SIGNFIXUP, used in conjunction with HOSTNUMMOVE and HOSTNUMCOMPARE, is intended to emulate the NUMPROC(NOPFD) behaviour
#EnterpriseDeveloper
#MFDS