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 Value

Former Member
0 Likes
1,217

Hallo

I want to check a Field for negative value

IF c_vkdfif-vbtyp = 'T'.

lv_netwr = -1 * ( lv_netwr + lt_vbap-netwr ).

ENDIF.

In another if I want to check when lv_netwr has a negative vlaue then do something.

How can I do it.

thanks.

7 REPLIES 7
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,081

Hello,

This is too simple.

IF lv_netwr < 0.
" Your logic
ENDIF.

Please try yourself before asking.

BR,

Suhas

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
1,081

Hi,

>

> Hallo

> I want to check a Field for negative value

> IF c_vkdfif-vbtyp = 'T'.

> lv_netwr = -1 * ( lv_netwr + lt_vbap-netwr ).

> ENDIF.

> In another if I want to check when lv_netwr has a negative vlaue then do something.

> How can I do it.

> thanks.

Just check:-


IF lv_netwr > 0.
  "code
ELSEIF lv_netwr < 0.
  "code
ENDIF.

Regards,

Tarun

Edited by: Tarun Gambhir on Mar 23, 2009 3:31 PM

Read only

Former Member
0 Likes
1,081

Thanks a lot I think I am sleeping.

Read only

Former Member
0 Likes
1,081

HI,

If lv_netwr LT '0'.  " IF lv_netwr hold negative values then contol goes inside the if condition 
* write you procrssing logic
ENDIF.

Read only

soumya_jose3
Active Contributor
0 Likes
1,081

Hi,

u can check the -ve value as

if lv_netwr < 0.

logic for negative

endif.

Regards,

Soumya.

Read only

Former Member
0 Likes
1,081

Hi Ahmad,

Try in this way

DATA 
  w_sign TYPE P.

w_sign = sign( lv_netwr ). 

IF c_vkdfif-vbtyp = 'T'.

  if w_sign = '1-'.
        lv_netwr = lv_netwr + lt_vbap-netwr.
 else.     
       lv_netwr = -1 * ( lv_netwr + lt_vbap-netwr ).
 endif.
 
ENDIF.

Regards,

Swapna.

Read only

0 Likes
1,081

Thanks a lot It solve my problem