Skip to Content
Former Member
Mar 12, 2007 at 10:31 AM

Loop Where



I am trying to use a where condition in my loop statement as follows:

LOOP AT lt_sales_orders WHERE sales_org = l_salesorg AND

division = l_division AND

distr_chan = l_distchan AND

sales_off = l_salesoff.

Here, l_salesorg, l_division, l_distchan, l_salesoff are <b>optional</b> input parameters. This query works well when all these input parameters are non-empty.

But if the user does not enter anything in any of the parameters, it tries to match it with a blank entry while I dont want that. Rather I just want to exclude the check for that parameter from my where clause. I know that we can use the 'if else elseif' statement to form a where clause.

But is there a better way of doing it?

( I cannot use the 'LIKE' operator )

Thanks and Regards,