Dick: you can redefine a packed decimal value to floating point by completely and totally changing the value, making it pretty much unrelated to the original value? Alternate explanation: person doing the posting has absolutely no clue about internal formats of packed decimal and floating point numbers?
Why not use
03 AMOUNT PIC S9(11)V99 COMP-3.
03 OUT-AMOUNT COMP-2.
IF AMOUNT NUMERIC
MOVE AMOUNT TO OUT-AMOUNT
Note that the IF test is critical since the original problem staement indicated that there's a very good chance the AMOUNT field is not numeric to start with.
Joined: 23 Nov 2006 Posts: 19270 Location: Inside the Matrix
I have a amount field in my Input file containing Comp-3 value and I want it to convert into comp-2 value .
Can I declare the Input amount field as AMOUNT PIC S9(11)V99 COMP-3.
and the output amount field as OUT-AMOUNT PIC S9(11)V99.
Why is comp-2 mentioned? Moving packed-decimal (PIC S9(11)V99 COMP-3) to zoned-decimal (PIC S9(11)V99) is completely valid - providing the comp-3 data is properly signed numeric. If it is not, there will be an 0c7.
Why do you believe you want/need floating-point? Rarely (if ever) is packed-decimal business data moved to a floating-point field. . .