‎2007 May 23 8:29 AM
Hi
Data : V1(10) type c value ' 123-',
sign_flag(1).
IF V1 < 0.
V1 = V1 * -1 .
sign_flag = 'X'.
ENDIF.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = V1
IMPORTING
OUTPUT = V1.
IF sign_flag = 'X'.
V1 = - ( V1 ).
ENDIF.
Write : V1.
<b>Above code is for Padding Leading Zeroes to Negative Number stored in field V1 with Data type C(10).</b>
Output of above code is = 123-
But I want it to be = 000000123-
How I can do that.
Do the correct modifications in the program.
Points will be given to the good ones.
Regards
Message was edited by:
Tulip Shah
‎2007 May 23 8:45 AM
IF sign_flag = 'X'.
V1 = '- 0000123'.
ENDIF.
Write : V1(10).
do this correction in ur code ..
bhanu
‎2007 May 23 8:36 AM
‎2007 May 23 8:39 AM
use this code/.....
Data : V1(10) type c value ' 123-',
v2(10) TYPE n,
v3(11) TYPE n,
sign_flag(1).
IF V1 < 0.
V1 = V1 * -1 .
sign_flag = 'X'.
ENDIF.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = V1
IMPORTING
OUTPUT = V1.
IF sign_flag = 'X'.
V1 = - ( V1 ).
ENDIF.
*v2 = v1.
move v1 to v2.
CONCATENATE v2 '-' into v3.
Write 😕 V1, / v3.
With Regards,
S.Barani
‎2007 May 23 8:45 AM
IF sign_flag = 'X'.
V1 = '- 0000123'.
ENDIF.
Write : V1(10).
do this correction in ur code ..
bhanu
‎2007 May 23 8:46 AM
Hi
No question of using the fun module
it is of no use
it won't accept signs.
use the following code.
it will work
Data : V1(10) type c value ' 123-',
n2(10) TYPE n,
n3(11) TYPE n,
sign_flag(1).
IF V1 < 0.
V1 = V1 * -1 .
sign_flag = 'X'.
ENDIF.
IF sign_flag = 'X'.
V1 = - ( V1 ).
ENDIF.
move v1 to n2.
CONCATENATE n2 '-' into n3.
Write 😕 n3.
Reward points if useful
Regards
Anji
‎2007 May 23 9:22 AM
Thanks for all your replys
All above answers are not meeting my requirement.
Regards
‎2007 May 23 9:23 AM
‎2007 May 23 9:29 AM
Hi,
try this out:
num = strlen(V1)
num2 = 10 - num.
do num2 times.
concatenate '0' V1 into V1.
enddo.
Reward if helpful,
Regards,
Sooness.