For Example:
01 TEST-NUMBER PIC S9(3)V9(3).
01 TEST-STRING PIC X(10).
MOVE 123,456 TO TEST-NUMBER.
MOVE TEST-NUMBER TO TEST-STRING.
Now I want to get "123,456" in TEST-STRING and not "123456" like Cobol
does it normally.
Normally we do it hard-coded like this
MOVE TEST-NUMBER(1:3) TO TEST-STRING(1:3).
MOVE "," TO TEST-STRING(4:1).
MOVE TEST-NUMBER(4:3) TO TEST-STRING(5:3).
but this isn't very flexible and the code must be changed everytime
the variable length is changed.
Best regards
Benedikt Gerlich
My COBOL is a bit rusty, but I think all you want is:
01 TEST-STRING PIC 999.999
(or ZZ9.999) if you want zero suppression.
I'm used to "." for a decimal point, but I seem to rememer a phrase "DECIMAL
POINTS IS COMMA" that might apply.
You might want to check or ask in comp.lang.cobol.
Scott
Benedikt,
though my cobol is also a bit rusty, you might try this or something similar.
77 WRK-NBR PIC X(30).
77 WRK-NBR-INT PIC 9(15) COMP
77 WRK-NBR-DEC PIC 9(15) COMP.
...
01 TEST-NBR PIC X(30).
....
MOVE SPACES TO WRK-NBR.
MOVE YOUR-NBR TO WRK-NBR..
* If 'YOUR-NBR' is equal to 123V456 'WRK_NBR-INT' would contain the Number of interger positions
* and 'WRK_NBR-DEC' the number of decimal positions
MOVE 3 TO WRK_NBR-INT.
MOVE 3 TO WRK_NBR-DEC.
* You may transform this subroutine in an external module as shown here
* CALL 'CONV' USING WRK-NBR WRK-NBR-INT WRK-NBR-DEC TEST-STRING
PERFORM CONV THRU CONV-EXIT.
MOVE TEST-STRING TO .....
......
CONV.
MOVE SPACES TO TEST-STRING..
MOVE TEST-NBR(1:WRK_NBR-INT) TO TEST-STRING(1:WRK_NBR-INT).
MOVE "," TO TEST-STRING(WRK_NBR-INT+1 : 1).
MOVE TEST-NBR(WRK_NBR-INT+2:WRK-NBR-DEC) TO TEST-STRING(WRK_NBR-INT+2: WRK_NBR-DEC).
CONV-EXIT.
EXIT.
HTH
Phil
Since your value could be signed you should use
a signed edit field.
01 TEST-NUMBER PIC S9(3)V9(3).
01 TEST-STRING PIC X(10).
01 Edit-Nbr pic 999.999-.
move TEST-NUMBER to Edit-Nbr.
move Edit-Nbr to TEST-STRING.
This should be all that's needed unless
you need zero-suppression. If so, then
change your edit field to be: ZZ9.999-
I assume, since your European, that the
default value for the decimal point is
the comma. If not, you'll also have to
use the "DECIMAL POINT IS COMMA" in your
program (as someone else already indicated).
HTH,
Terry
So when the length in the database file changes I dont't want to
change anything in the code except recompiling it.
Terry Winchester <terrywi...@pronetisp.net> wrote in message news:<72al2vkri4449qlpu...@4ax.com>...