Application Development and Automation 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: 
Read only

remove negative and adding ( )

Former Member
0 Likes
1,431

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
Read only

Former Member
0 Likes
1,401

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
Read only

Former Member
0 Likes
1,401

try bellow codes:

REPORT ztest.

data: p type p value '-127.5'.

p = p * -1.

write p.

Read only

JozsefSzikszai
Active Contributor
0 Likes
1,401

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

Read only

Former Member
0 Likes
1,401


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

v_var = v_var * -1.

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


Read only

Former Member
0 Likes
1,401

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

Read only

Former Member
0 Likes
1,401

Hi experts.

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

Read only

0 Likes
1,401

use the code i provided

Read only

Former Member
0 Likes
1,401

Multiple the Value with -1

Concatenate '(' value ')' into text.

Regards

Kumar

Read only

0 Likes
1,401

hi Nannapaneni Kumar .

I tried but it is giving error.

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

Read only

0 Likes
1,401

Hi Saravanan,

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

Regards,

Swapna.

Read only

0 Likes
1,401

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

Regards,

Kumar

Read only

former_member189059
Active Contributor
0 Likes
1,401

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

Read only

Former Member
0 Likes
1,402

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

Read only

0 Likes
1,401

Kunjal Patel ,

Your coding given me the solution.

thanks you very much.