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: 

Finding if an integer value is negative or positive.

Former Member
0 Kudos

Hi,

How can I find if a variable which has been defined as an integer is negative or positive?

Ex:

Paramaters: var type i.

When the user enters some value, how can I find if he has entered negative or positive??

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi!

Data zero type i value is initial.

...

at selection-screen.
  if var < zero.
    message e999 with 'Value is less than zero'.
  else.
    message e999 with 'Value is greater than zero'.
  endif.

Cheers,

John

3 REPLIES 3

Former Member
0 Kudos

Hi!

Data zero type i value is initial.

...

at selection-screen.
  if var < zero.
    message e999 with 'Value is less than zero'.
  else.
    message e999 with 'Value is greater than zero'.
  endif.

Cheers,

John

Former Member
0 Kudos

Hello,

If you whant to know that just write:

Data resp type i.

if var < 0.

resp = 0. " Its negative

elseif var >= 0

resp = 1. " Its positive.

....

then use resp to do what you want.

0 Kudos

If u have it in the selection screen do a validation in at selection-screen event.

At selection screen.

if p_var < 0.

message e000 with 'the value is negative'.

endif.