Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PIC Z(08)9.9(02). 3

Status
Not open for further replies.

claudeb

Programmer
Nov 23, 2000
140
CA
hi
in order to strip off the leading zeros in my R-AMT
i declared it as
05 R-AMT PIC Z(08)9.9(02).
instead of
05 R-AMT PIC 9(08)V9(02).
in the program , i do few computations:
MOVE 0 TO R-AMT
COMPUTE R-AMT ROUNDED =....
ADD 10 TO R-AMT

i get this error for the "ADD" statement:
IGYPA3074-S "R-AMT (NUMERIC-EDITED)" was not numeric, but was a sender in an arithmetic expression. The statement was discarded.
any idea why ?
thanks
 
try changing the declaration of R-AMT to Z(08).9(02). The 9 after the Z(08) may be the problem. May be worth a try.
 
claudeb,
You need to define two fields, one to do the arithmetic function , then one to edit the data, for example:
05 r-amt pic 9(8)v99.
77 ed-amt pic z(8).99.
move 0 to r-amt.
add 10 to to r-amt.
move r-amt to ed-amt.
 
To try to answer your question - why does the add fail....

You can MOVE into an numeric editing field. You can COMPUTE into it. You can even ADD into it, if it is the destination field and not one of the operands. However, it cannot be one of the operands of a computation because it really doesn't contain numeric data! You can keep your definition in this case, and simply alter your compute statement.

Your code:

MOVE 0 TO R-AMT

You don't need this move 0, the compute will take care of this.

COMPUTE R-AMT ROUNDED =....
ADD 10 TO R-AMT

Change to:

Compute R-amt Rounded = (....) + 10

Now the only potential for trouble is that the rounding will occur after the 10 is added, but since you are not rounding at that level the answers should always be the same.




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top