my aim is to reduce that elseif statements, I am still working on this report today I have been asked to include one more field on selection screen now I have total 4 parameters on selection screen which means possibility of 16 different choices (4*4).
here how my internal table filtering looks like now
*--------------------------------------------------------------------------*
* Form Filter_records *
*--------------------------------------------------------------------------*
* Filter records in internal table according to selection screen
*--------------------------------------------------------------------------*
Form Filter_Records.
if INCI NE '' and P_PRIO ne '' and status ne '' and MODD ne ''.
LOOP AT ITABLE into WA_ITABLE where OBJECT_ID = inci and TXT_LONG(1) = P_PRIO and TXT30 = STATUS and COMP = MODD.
append WA_ITABLE to ITABLE2.
ENDLOOP.
elseif INCI = '' and P_PRIO = '' and STATUS = '' and MODD = ''.
LOOP AT ITABLE into WA_ITABLE.
APPEND WA_ITABLE to ITABLE2.
ENDLOOP.
ELSEIF inci NE '' and P_PRIO = '' and status = '' and MODD = ''.
LOOP at ITABLE into WA_ITABLE where OBJECT_ID = INCI.
APPEND WA_ITABLE to ITABLE2.
ENDLOOP.
ELSEIF inci NE '' and P_PRIO NE '' and status = '' and MODD = ''.
LOOP at ITABLE into WA_ITABLE where OBJECT_ID = inci and TXT_LONG(1) = P_PRIO.
APPEND WA_ITABLE to ITABLE2.
ENDLOOP.
ELSEIF INCI NE '' and P_PRIO = '' and status NE '' and MODD = ''.
LOOP AT ITABLE into WA_ITABLE where OBJECT_ID = INCI and TXT30 = STATUS.
APPEND WA_ITABLE to ITABLE2.
ENDLOOP.
ELSEIF INCI NE '' and P_PRIO = '' and status = '' and MODD NE ''.
LOOP AT ITABLE into WA_ITABLE where OBJECT_ID = INCI and COMP = MODD.
APPEND WA_ITABLE to ITABLE2.
ENDLOOP.
ELSEIF INCI NE '' and P_PRIO NE '' and status NE '' and MODD = ''.
LOOP AT ITABLE into WA_ITABLE where OBJECT_ID = INCI and TXT_LONG(1) = P_PRIO and TXT30 = STATUS.
APPEND WA_ITABLE to ITABLE2.
ENDLOOP.
ELSEIF INCI NE '' and P_PRIO = '' and status NE '' and MODD NE ''.
LOOP AT ITABLE into WA_ITABLE where OBJECT_ID = INCI and TXT30 = STATUS and COMP = MODD.
APPEND WA_ITABLE to ITABLE2.
ENDLOOP.
ELSEIF INCI NE '' and P_PRIO NE '' and status = '' and MODD NE ''.
LOOP AT ITABLE into WA_ITABLE where OBJECT_ID = INCI and TXT_LONG(1) = P_PRIO and COMP = MODD.
APPEND WA_ITABLE to ITABLE2.
ENDLOOP.
ELSEIF INCI = '' and P_PRIO NE '' and status = '' and MODD = ''.
LOOP AT ITABLE into WA_ITABLE where TXT_LONG(1) = p_prio.
APPEND WA_ITABLE to ITABLE2.
ENDLOOP.
ELSEIF INCI = '' and P_PRIO NE '' and status NE '' and MODD = ''.
LOOP AT ITABLE into WA_ITABLE where TXT_LONG(1) = P_PRIO and TXT30 = status.
APPEND WA_ITABLE to ITABLE2.
ENDLOOP.
ELSEIF INCI = '' and P_PRIO NE '' and status = '' and MODD NE ''.
LOOP AT ITABLE into WA_ITABLE where TXT_LONG(1) = P_PRIO and COMP = MODD.
APPEND WA_ITABLE to ITABLE2.
ENDLOOP.
ELSEIF INCI = '' and P_PRIO NE '' and status NE '' and MODD NE ''.
LOOP AT ITABLE into WA_ITABLE where TXT_LONG(1) = P_PRIO and TXT30 = STATUS and COMP = MODD.
APPEND WA_ITABLE to ITABLE2.
ENDLOOP.
ELSEIF INCI = '' and P_PRIO = '' and status NE '' and MODD = ''.
LOOP AT ITABLE into WA_ITABLE where TXT30 = STATUS.
APPEND WA_ITABLE to ITABLE2.
ENDLOOP.
ELSEIF INCI = '' and P_PRIO = '' and status NE '' and MODD NE ''.
LOOP AT ITABLE into WA_ITABLE where TXT30 = STATUS and comp = MODD .
APPEND WA_ITABLE to ITABLE2.
ENDLOOP.
ELSEIF INCI = '' and P_PRIO = '' and status = '' and MODD NE ''.
LOOP AT ITABLE into WA_ITABLE where comp = MODD .
APPEND WA_ITABLE to ITABLE2.
ENDLOOP.
ENDIF.
IF sy-SUBRC NE 0.
MESSAGE 'Sorry, no records found with specified criteria.' TYPE 'W' DISPLAY LIKE 'E'.
STOP.
ENDIF.
ENDFORM.