One way would be to build a dynamic QMQRY using SETVAR to determine your selection criteria. Since you may have more than 1 selection criteria, I would build 7 different SQL with 1 to 7 selection criteria:
Select * from MYTABLE where &F1 = &F2
Select * from MYTABLE where &F1 = &F2 OR &F3 between &F4 and &F5
and so on…
Then, write a CL program passing parameters and based on the number of parameters passed, execute the proper QMQRY passing parameters.
Dont forget to add additionnal bracket whenever passing data content variable.
Put the result of your QMQRY into a temporary file in QTEMP for example and access that file by the RRN using a SETLL int your RPG to read the information and put it onto your subfile.
This way, you will have a full flexible procedure no matter how many selection criteria are selected.
Have fun !
if you are talking about a SQL query here is a code example:
SELECT * FROM MYTABLE WHERE
FaxRefereneceNumber LIKE ‘%XXXXXX XXXXXX%’
OR Orderdate BETWEEN #XX/XX/XX# AND #XX/XX/XX#
OR Contractnumber LIKE ‘%PKXXXXX PKXXXXX%’
OR Item LIKE ‘%XXXXXXXXX XXXXXXXXX%’
OR Warehouse LIKE ‘%XXX XXX%’
OR Vendor LIKE ‘%XXXXXX XXXXXX%’
I hope this helps.