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

changing negative value

Former Member
0 Likes
2,711

Hi,

In my code am retriving one value with select statement..

that value I am getting is with minus sign..

i need to cange it to positive...

can you suggest the best syntax as per performance.....?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,956

Hi Shruthi,

Use:

value = value * -1.

Or

value1 = ABS(value).

Regards,

Nitin.

Edited by: Nitin Karamchandani on Feb 23, 2009 11:39 AM

9 REPLIES 9
Read only

Former Member
0 Likes
1,956

Aftre getting the value

Multiply it by -1.

Regards,

Prashant

Read only

Former Member
0 Likes
1,956

hi.....

for this thing if you are getting the value in data object W_VALUE

GO FOR FOLLOWING STATMENT BEFORE YOU GO FOR DISPLAY OR PROCESSING THIS WILL GIVE YOU A VALUE WITHOUT SIGN IF ANY IS THERE

W_VALUE = ABS( W_VALUE ).

REGARDS

Edited by: Mohit Kumar on Feb 23, 2009 11:37 AM

Read only

Former Member
0 Likes
1,956

Hi Check the link

Regards

Sachin

Read only

Former Member
0 Likes
1,957

Hi Shruthi,

Use:

value = value * -1.

Or

value1 = ABS(value).

Regards,

Nitin.

Edited by: Nitin Karamchandani on Feb 23, 2009 11:39 AM

Read only

0 Likes
1,956

Hi,

Please Test the following Sample Code and try to use ABS rather than multiply by -1 if you need all the Values Positive because if you will use Multiply by -1 it will convert your Positive Values to Minus Too.

DATA: BEGIN OF it OCCURS 5,
  amount TYPE i,
  END OF it.

it-amount = '75'.
APPEND it TO it.
it-amount = '-12'.
APPEND it TO it.
it-amount = '-20'.
APPEND it TO it.
it-amount = '55'.
APPEND it TO it.


LOOP AT it into it.

  it-amount = abs( it-amount ).
  MODIFY it from it.
  WRITE: / it-amount.

ENDLOOP.

Kind Regards,

Faisal

Read only

0 Likes
1,956

Hi All,

Thanks for your replies.

Read only

Former Member
0 Likes
1,956

value = ABS( value )

ABS = Absolute value of the argument

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,956

multiply it by -1

Read only

former_member222860
Active Contributor
0 Likes
1,956

Hi,

See this thread