There is a variable with value 19446. Requirement is to
convert it to 194.46. I tried it by doing divide by 100 and
my receiving field data type is 9(03)v99. But the output is
194. I am not getting the decimal value. Could anyone pls
let me know how to get this done?
Answers were Sorted based on User's Feedback
Answer / kiro
When COBOL does a divide it uses the format of the item
which in this case is integer only that is why the
fractional part is missing. You need to move the value
19446 to a 9(5)v99 item first and then do the divide using
the 9(5)v99 item.
| Is This Answer Correct ? | 7 Yes | 0 No |
To make this we require to use redefines.
01 ws-value-change
05 WS-ALPHANUMERIC PIC X(5).
05 WS-NUMERIC REDEFINES WS-ALPHANUMERIC PIC 9(3)
V99.
011 WS-EDITED-NUMERIC PIC 9(3).99.
PROCEDURE DIVISION
MOVE '19446' TO WS-ALPHANUMERIC
MOVE WS-NUMERIC TO WS-EDITED-NUMERIC
DISPLAY WS-EDITED-NUMERIC
STOP RUN
You will get the value as 194.46
| Is This Answer Correct ? | 7 Yes | 0 No |
how you will define variables length in cobol.
what is difference between the sysabend and userabend?
can u plz expain me how to declare dynamic array? what is the meaning of depending on clause in dynamic array?
What R 2 of the common forms of the EVALUATE STATEMENT ?
is it possible to rename 01 level?
Can we use goto statement in inline_perform ?
I have two questions here. 1. How to read a flat file in reverse order? 2. How to read a VSAM KSDS file in reverse order? In both the cases we donot know the total number of records.
What rules are followed by the search verb.
Are you comfortable in cobol or jcl?
How to read a record from bottom of a file which is indexed by 'A'.
what is the maximum error code in mainframe
Name some of the examples of COBOl 11?