I would like to ask how to do a basic search filtering in a selection screen that has multiple input fields which aren't required.
I tried to do it by using multiple IF statements followed by WHERE clauses which solves my current problem but its not fully correct, if i work with only a few inputs (2 at the moment, 'ID' and 'Number'), the code isn't too long, but if its over 10 or so it feel wrong to do it this way
What i tried so far was approximately like this :
IF lv_id IS INITIAL and lv_nr IS INITIAL.
SELECT * from DBase INTO TABLE Local_Table.
ELSEIF lv_id IS NOT INITIAL AND lv_nr IS INITIAL.
SELECT * from DBase INTO TABLE Local_Table WHERE ID = lv_nr.
ELSEIF lv_id IS INITIAL AND lv_nr IS NOT INITIAL.
SELECT * from DBase INTO TABLE Local_Table WHERE Number = lv_nr.
ELSEIF lv_id IS NOT INITIAL AND lv_nr IS NOT INITIAL.
SELECT * from DBase INTO TABLE Local_Table WHERE ID = lv_id AND Number = lv_nr.
The expected result is for the search to get executed correctly by having no input or multiple non-obligatory inputs, without having to write a very long code in case the number of inputs is high.