Assigning a T-Code to an ABAP Query can be done in two ways. By first method, you assign Query Program Name to the T-Code. In second, you assign the Query directly to the T-Code.
It is recommended not to assign Query program name directly to trnasaction code in case of queries(prefer method 2 than method 1), because Queries are generated and may vary system by system. But I have seen first being used more.
Run the sap query from SQVI and when your input field will come then click on (menus) system->status then copy the program name from there.
Then go to transaction se93, there you put the program name that u copied and click 3 check boxes (of gui support) then save the transaction by giving your customised tcode.
Create a Transaction calling transaction START_REPORT with the following parameters/attributes filled :
D_SREPOVARI-REPORTTYPE= AQ “parameter indicating Abap Query
D_SREPOVARI-REPORT= ‘ZGRP’ “Query User group
D_SREPOVARI-EXTDREPORT= ‘ZNAME’ “Query name