Hi Aryat,
Yes it is possible to include code in infoset and fetch data from database tables.
Go to tcode- SQ02, and change query area from global->standard and click change.
Now click on Extras,it will enable all the custom fields on right hand side.
Now select the field from the row and click coding for addition symbol as mentioned in below screen shot, it will take you to the program line screen and you can code here.
After completing coding save and generate the infoset and adjust the query again otherwise new changes will not reflect.
Hope it will solve your issue.