Skip to Content

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

function module

for 3x + 4y + 2z LE 25 i want all possible values can any body suggest me.pls?

Former Member
Former Member replied

Hello

Try this code:

data: x type i,
      y type i,
      z type i,
      sum type i.
data: begin of itab occurs 0,
      x type i,
      y type i,
      z type i,
end of itab.
x = y = z = 0.
do 6 times.
  x = x + 1.
  do 5 times.
    y = y + 1.
    do 9 times.
      z = z + 1.
      sum = x * 3 + y * 4 + z * 2.
      if sum <= 25.
        itab-x = x.
        itab-y = y.
        itab-z = z.
        append itab.
      endif.
    enddo.
    z = 0.
  enddo.
  y = 0.
enddo.

In result table ITAB will be all possible values (natural numbers, without zeros).

If you need with zeros - modify this code itself

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question