NUMPROC(NOPFD):This
makes the compiler to perform invalid sign processing
NUMPROC(PFD)
:This option bypasses the invalid sign
processing.
The
difference between the two options is explained through the below
example
CODE:
WORKING-STORAGE
SECTION.
01
WS-VAR
PIC X(2) VALUE "5-".
01
WS-VAR-1
PIC 9(2).
PROCEDURE
DIVISION.
MOVE
WS-VAR TO WS-VAR-1
DISPLAY
WS-VAR-1.
IF
WS-VAR-1 IS NUMERIC
DISPLAY
"THE FIELD IS NUMERIC"
ELSE
DISPLAY
"THE FIELD IS NOT NUMERIC"
END-IF.
OUTPUT When
NUMPROC(NOPFD) is used:
50
THE
FIELD IS NUMERIC
OUTPUT When
NUMPROC(PFD) is used:
5-
THE
FIELD IS NOT NUMERIC
Depending
upon the option used the same code produces different results.:
Reason
When NOPFD
option is used it performs invalid sign processing. In our case “5-“
hex value is “F560”.The sign value for the field is X’6’
which is an invalid sign value(valid sign values:
X’C’-positive.X’D’-negative,X’F’-unsigned and by default
they occupy higher order 4 bits of last byte).The general rule in
data movement is, when sending data item is alphanumeric field and
the receiving field is unsigend numeric,the sending field is treated
as unsigned numeric(this is the reason we are able to move
non-numeric value stored in Alphanumeric field to numeric field and
not move non-numeric value directly to the numeric field).Since the
sending field is treated as unsigned numeric the invalid sign value
X’6’ is converted to X’F’ and the value becomes “F5F0”
which is 50 in decimal and so our output.
When PFD
option is used the invalid sign processing is not done the value is
directly moved to the numeric field without any processing.
Conclusion:
This kind of
situation may occur mainly in CICS programs where the screen field is
defined as alphanumeric.When value is entered wrongly in the screen
field and if numeric condition is checked for the field, correct
results will be produced depending on the correct option used(PFD in
our case).Disadvantage in using NOPFD option is ,it increases the
object code size and there could be an
increase in run-time overhead to validate all signed data. So
depending on our requirements appropriate option could be used.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.