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

Finding if an integer value is negative or positive.

Former Member
0 Likes
5,754

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

Former Member
0 Likes
2,126

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

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??

3 REPLIES 3
Read only

Former Member
0 Likes
2,127

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

Read only

Former Member
0 Likes
2,126

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.

Read only

0 Likes
2,126

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.