Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

remove negative and adding ( )

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

13 REPLIES 13

Former Member
0 Kudos

try bellow codes:

REPORT ztest.

data: p type p value '-127.5'.

p = p * -1.

write p.

JozsefSzikszai
Active Contributor
0 Kudos

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

Former Member
0 Kudos


data: v_var(12) type p decimals 4 value '152.26-'.

v_var = v_var * -1.

write:/ '(',v_var, ')'.


Former Member
0 Kudos

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

Former Member
0 Kudos

Hi experts.

No only need to remove the negative i also need to add the bracket ( value )

0 Kudos

use the code i provided

Former Member
0 Kudos

Multiple the Value with -1

Concatenate '(' value ')' into text.

Regards

Kumar

0 Kudos

hi Nannapaneni Kumar .

I tried but it is giving error.

Ther error the variable should be in c , n and etc.

0 Kudos

Hi Saravanan,

Please try the modified code i pasted above. It is working

Regards,

Swapna.

0 Kudos

After multiplying the value with -1 move the value into Char variable and concatenate

Regards,

Kumar

former_member189059
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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

0 Kudos

Kunjal Patel ,

Your coding given me the solution.

thanks you very much.