Reputation: 1
Looking for solution on my problem. The values I need to convert was in alphanumeric.
05 WS-NUM-TX.
05 WS-NUM PIC P9(04).
05 WS-NUM1 PIC P9(03).
05 WS-NUM2 PIC P9(03).
MOVE '0001 222217' TO WS-NUM-TX.
MOVE WS-NUM-TX(1:4) TO WS-NUM.
MOVE WS-NUM-TX(6:3) TO WS-NUM1.
MOVE WS-NUM-TX(9:3) TO WS-NUM2.
I did COMPUTE WS-NUM = FUNCTION NUMVAL(WS-NUM-TX)
for this to be numeric.
Now, the problem is, I need this values as decimal for computation. Need help to convert this values to become .0001, .222 and .217
however the declaration
I did for external decimal displayed with no decimal point. Please help. Thank You.
Upvotes: 0
Views: 316
Reputation: 4407
The P
in the PICTURE
clause is an error, as is the absence of a PICTURE
clause for WS-NUM-TX
. (As of the the 4th revision.)
Possibly,
05 WS-NUM-TX PIC X(11).
05 WS-NUM PIC .9(04).
05 WS-NUM1 PIC .9(03).
05 WS-NUM2 PIC .9(03).
MOVE '0001 222217' TO WS-NUM-TX.
COMPUTE WS-NUM = FUNCTION NUMVAL (WS-NUM-TX(1:4)) / 10000.
COMPUTE WS-NUM1 = FUNCTION NUMVAL (WS-NUM-TX(6:3)) / 1000.
COMPUTE WS-NUM2 = FUNCTION NUMVAL (WS-NUM-TX(9:3)) / 1000.
Based on the original post (revisions 1 and 2) with additional editing.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 FILLER.
05 WS-NUM-TX.
07 WS-NUM-TX1 PIC 9(4).
07 FILLER PIC X.
07 WS-NUM-TX2 PIC 9(3).
07 WS-NUM-TX3 PIC 9(3).
05 WS-NUM PIC .9(04).
05 WS-NUM1 PIC .9(03).
05 WS-NUM2 PIC .9(03).
PROCEDURE DIVISION.
BEGIN.
MOVE '0001 222217' TO WS-NUM-TX.
DIVIDE WS-NUM-TX1 BY 10000 GIVING WS-NUM.
DIVIDE WS-NUM-TX2 BY 1000 GIVING WS-NUM1.
DIVIDE WS-NUM-TX3 BY 1000 GIVING WS-NUM2.
DISPLAY WS-NUM
DISPLAY WS-NUM1
DISPLAY WS-NUM2
STOP RUN
.
Output:
.0001
.222
.217
Upvotes: 1
Reputation: 188
Use V
in the picture clause. This determines the position of the comma.
For example: PIC 9(05)V9(03)
will result in 00000,000
Upvotes: 0