RUNQRY
does not support variables.
You can define variables in the Query/400 query, but you must use the Start Query Management Query (STRQMQRY)
command to run the query.
Be sure to specify:
Allow information from QRYDFN . ALWQRYDFN *YES`
Here's an IBM document that shows how to do it.
Select Records
Type comparisons, press Enter. Specify OR to start each new group.
Tests: EQ, NE, LE, GE, LT, GT, RANGE, LIST, LIKE, IS, ISNOT...
AND/OR Field Test Value (Field, Number, 'Characters', or ...)
GLCOMP EQ :COMPANY
AND GLBRAN EQ :BRANCH
AND GLACC EQ :ACCOUNT
-----------------------------------------------------------------------
STRQMQRY QMQRY(library/qry-name) ALWQRYDFN(*YES) +
QMFORM(*QMQRY) SETVAR((COMPANY 1) (BRANCH 1) (ACCOUNT 12000))