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

negative to positive amount

Former Member
0 Likes
1,317

hi all,

i got one scenario that i have got 2 amounts

one is with value 200.00 and other value 100.00-

so now i have to convert 100.00- to 100.00

and comapre that out of 200 & 100 which is greater.

then calculate the profit & loss by subtracting these amount.

u may be confused that why can't we comapre directly 200 & 100-

directly . but let me tell u that it will be problem bcoz if we will subtract 100- from 200 then we will get 300 which will be wrong.

so my requirement is to relace the neagtive sign from the amount

then only compare these two amounts and then only calculate profit & loss.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,216

if amount lt 0.

v_amount = amount * ( -1 ).

endif.

now compare with v_amount,

regards

shiba dutta

8 REPLIES 8
Read only

Former Member
0 Likes
1,217

if amount lt 0.

v_amount = amount * ( -1 ).

endif.

now compare with v_amount,

regards

shiba dutta

Read only

Former Member
0 Likes
1,216

hi

you have two methods.

first one is add the variables. then 200 and 100- will become 100. that would give u a result.

another method is...

var1 contains '200'.

var2 contains '100-'.


if var2 LT 0.
  var2 = var2 * ( -1 ).
  if var1 LT var2.
  -- 
  --
  --
  endif.
endif.

thx

pavan

Read only

Former Member
0 Likes
1,216

hi Sanjeev,

i think there is no need of comparing and then subtracting one value from the other. you just add both those values and if the sum is greater than '0' then it is profit else it means that its a loss.

if i've answered u right award points.

Kiran

Read only

Former Member
0 Likes
1,216

Hi sanjeev,

if u r using scripts ,

&symbol(s)&

<b>&itcdp-tdulpos& -


> 100-

&itcdp-tdulpos(s)& -


> 100

</b>

if u r using reports,

suppose v_field1 contains 100- then,

v_field1 = v_field1 * (-1)

then do u r comparision

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,216

Hi,

v1 = abs( 100.00-).

Then compare.

Read only

Former Member
0 Likes
1,216

thanks for solving my issue.

i have rewarded all ur efforts

Read only

Former Member
0 Likes
1,216

Hi All,

there are many ways of doing that. Suppose there are two variables v1 and v2.

v1 = 100-.

v2 = 200.

Method 1: if abs(v1) gt abs(v2).

Method 2 : replace '-' in v2 with ''

Method3:

if v2 lt 0.

v2 = v2 * -1.

endif.

Read only

Former Member
0 Likes
1,216

Hi Sanjeev ,

I have a doubt reagading this concept what is you have the values 100 and 200- , then you will get 100 as diffrence , but actually it must be 100-.

Why dont you just add all the values to get the profit/loss details.

Regards

Arun