09-09-2008 9:08 AM
Hi experts,
I have variable v_var(12) type p decimals 4.
The default value is 152.26-.
I need to remove the negative and the output should be like this ( 152.26 ).
I tried to concatenate but it is giving error.
Please guide me.
Thank you very much.
regards,
s.saravannan
09-09-2008 9:27 AM
Hi,
If you want to remove the negative sign then you can use the ABS keyword as mentioned earlier in the response...
If you want to concatenate then you need to move this value into a field having data type CHAR....
Use the following code:
DATA tmp type string.
MOVE v_var to tmp.
CONCATENATE '(' tmp ')' INTO tmp SEPERATED BY SPACE.
Hope this helps..
Regards,
Kunjal
09-09-2008 9:14 AM
try bellow codes:
REPORT ztest.
data: p type p value '-127.5'.
p = p * -1.
write p.
09-09-2008 9:14 AM
hi,
v_var = ABS( v_var ).
this will always make the value positive, irrelevant if the original value was positive or negative
hope this helps
ec
09-09-2008 9:15 AM
data: v_var(12) type p decimals 4 value '152.26-'.
v_var = v_var * -1.
write:/ '(',v_var, ')'.
09-09-2008 9:15 AM
Hi Saravanan,
Your code would be :
DATA :
v_var(12) TYPE p DECIMALS 4 VALUE '-152.26',
v_var1(12) type c,
v_concat(30) type c.
v_var = v_var * -1.
move v_var to v_var1.
concatenate '(' v_var1 ')' into v_concat.
WRITE : v_concat.
Regards,
Swapna.
Edited by: NagaSwapna Thota on Sep 9, 2008 1:52 PM
09-09-2008 9:16 AM
Hi experts.
No only need to remove the negative i also need to add the bracket ( value )
09-09-2008 9:19 AM
09-09-2008 9:16 AM
Multiple the Value with -1
Concatenate '(' value ')' into text.
Regards
Kumar
09-09-2008 9:19 AM
hi Nannapaneni Kumar .
I tried but it is giving error.
Ther error the variable should be in c , n and etc.
09-09-2008 9:24 AM
Hi Saravanan,
Please try the modified code i pasted above. It is working
Regards,
Swapna.
09-09-2008 9:38 AM
After multiplying the value with -1 move the value into Char variable and concatenate
Regards,
Kumar
09-09-2008 9:22 AM
From what I see the problem is since you are using type P which doesn't accept parenthesis symbols
Hence you will need to move your result output to a character type variable
09-09-2008 9:27 AM
Hi,
If you want to remove the negative sign then you can use the ABS keyword as mentioned earlier in the response...
If you want to concatenate then you need to move this value into a field having data type CHAR....
Use the following code:
DATA tmp type string.
MOVE v_var to tmp.
CONCATENATE '(' tmp ')' INTO tmp SEPERATED BY SPACE.
Hope this helps..
Regards,
Kunjal
09-09-2008 9:39 AM
Kunjal Patel ,
Your coding given me the solution.
thanks you very much.