Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to display even and odd number ranges between two given inputs.

Hi Every one,

I am just started my career in sap abap and trying to find the solution for this.

I am trying to display number range using select options, but I am getting an error "Memory low leave the transaction before taking a break".

Example: when I give two number 2 and 10 , it should display set of all even and odd numbers in that range.

Below is the code logic that I am using:

data: a type i,

         b type i,

         c type i,

         d type i,

         num type i.

select-options: in for num.

a = inp-low.

b=inp-high.

c = inp-low mod 2.

d = inp-high mod 2.

while a <=b and c = 0.

write: "even numbers:', a.

b = a + 1.

endwhile.

while a <=b and c <> 0.

write: "odd numbers:', b.

b = a + 1.

endwhile.

Any help will be much appreciated.

Former Member
Former Member replied

This is your logic...changed:

data: a type i,

          b type i,

          c type i,

          d type i,

          num type i.

data: even type i,

       odd  type i.

select-options: in for num.

a = in-low.

b = in-high.

c = a mod 2.

if c is INITIAL. "It measn a is even

   even = a.

   odd  = a + 1.

else.

   odd  = a.

   even = a + 1.

endif.

* Even

a = even.

while a <= b.

   write: / 'even numbers:', a.

*  b = a + 1.

   a = a + 2. "The next even number

endwhile.

* Odd

a = odd.

while a <= b .

   write: / 'odd numbers:', a.

   a = a + 2. "The next odd number

endwhile.

1 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question