Michael,
Two suggestions:
1) If the table Miguel has suggested (RSEQ_DIR) holds the mapping of query to FM, you can look up the FM name via your ABAP code and then call the FM via variable (i.e. CALL FUNCTION LV_FMNAME vice CALL FUNCTION 'Literal FM Name').
2) If this table does not hold this relationship, you could always create a Z table to hold this mapping for a similar implementation to solution #1 which would then be a solution for all of your queries vice having to create copies (Z FM's from templates) each time.
Regards,
Chad