You need to determine the requirements:
(a)Inputs – which infotypes, etc; check which infoset has all the infotypes.
If you need to obtain data from Time eval or Pay results, then you need to check if the data is available as an infotype or from tables from a cluster like the PCL1 or PCL, then you need to check if the access methods are available and how to access in a query.
(b)Selection criteria- for the different data.
(c)Output – columns, sequence, format, etc.
Then determine the solution. Many times the Adhoc query with txn SQ01 may not be suitable. For example, in a reporting & selection period, if you select active employees, the output will have all the employees active in that period, not just the ones currently active. Or you may need to derive an output field based on other fields in infotypes or tables. While you may be able to call a function in SQ01 query, it may not be totally correct. So in such cases you will need to create a program.
If you can use SQ01, then
(1) in txn SQ02, determine which infoset satisfies your needs.
If necessary, you may need to (i)add an infotype to the infoset or (ii)activate a field in an infotype , or (iii)add an additional field to an infotype.
Check if the infoset is ok to be used or needs adjustment. Then if required generate the infoset.
(2)Txn SQ01: Select infotypes, then fields in each IT for input or/and output, then add any ABAP code as required, then format the output as required.
Test the query; Save and generate the query; it will be saved as a program. You can give it a suitable name. You can use this in a periodic or adhoc job.
Hope this helps.