What I meant is that you code the query in the mapping expression for the variable in the Report Rule. I did this to get a variable filled with the user's email address:
string email.address(100) mb
email.address = ""
where ttcmf200.catg = "BAAN USER"
and ttcmf200.akey = :1
and ttcmf200._compnr = 0
as set with 1 rows
wherebind (1, toupper$(logname$))
Select the Report Rule variable and start the text manager to create text and type your code.