SAP Query is a tool provided by SAP to define and view reports without knowing ABAP programming language. Here the users need to define the Infosets (group of Infotypes with selected fields) and based on those infosets the relevant report can be executed and extracted as per the requirement. The reports can be created in various formats i.e. Basic list, statistics and ranked list.
The transaction codes for creation of ABAP Query are:
SQ02 – Infoset creation
SQ03 – User group creation
SQ01 – ABAP Query
It’s a three stepped process:
1. Creation of Infoset
2. Creation of user group
3. Creation of queries
Step 1: Creation of Infosets
In this step we need to select all the infotypes from which the data is going to be extracted during the reporting. Here we can also restrict the fields which we require in a particular infotype. The LDB for HR can be used here depending on the requirement.
Go to T. code – SQ02, give a name starts with Z, say CREATE
Below given screen will appear.
- Give the LDB name. Here I have taken PNPCE
- Radio Button should be on LOGICAL DATABASE with inputs as PNPCE
- Press ENTER or click on tick mark
The below screen appears:
Like the 1st option, go to the drop down & check mark all those Infotypes which are necessary & press ENTER or click tick mark.
From the field Group/data fields on the right hand panel the un-necessary fields can be excluded.
Now click on GENERATE button or shift+F6.
In the above screen click on Local Object. At the footer of screen a message will appear about the GENERATION of Infoset.
Step 2: Creation of User Group
The user groups are created to assign the users with particular authorization to access those infosets and fields.
SQ03 is the T-code to create the User Group.
Give a name starts with Z & Infoset should be there & click CREATE & below is the next screen.
Give a User Group name & click SAVE or tick mark. Below screen will come.
On the above screen click LOCAL OBJECT & on the bottom left-hand corner you will see the message “User Group saved”.
Now in the screen of SQ03, press Assign Users and Infosets & the below screen comes.
Above is the next screen & in the blank fields just enter the USER names to handle the QUERY as given above & click ASSIGN INFOSETS to see the below screen.
Scroll down to Your Infoset then put a check mark & click save. A message appears “User Group saved”.
Step 3: Creation of queries
Queries are created based on the infosets defined.
Come to T.code SQ01 & see the created USER GROUP name along with INFOSET as given below
Give a name to your Query & say CREATE to get the below screen with your INFOSET.
Select your INFOSET & proceed to below screen.
Just give a Title Name that starts with ‘Z’ & click BASIC LIST & see the below screen.
Fill in with the necessary requirements for the with the help of TICK BOX & click SAVE.
After clicking on DISPLAY REPORT NAME the below screen appears.
Go to SE93 for the below screen
Give it a small name because it as a T.code for this report & click CREATE , then the below screen appears.
Give it a short text & place your radio button on PROGRAM & SELECTION SCREEN.
After placing your radio button there, then press ENTER & get the below screen.
Just provide the Report Name u got from the above 2 screen & click SAVE & get next screen.
Then just press LOCAL OBJECT & this message appears “Transaction code saved” on bottom left.
Thus we are done with the creation of SAP Queries and thus report along with T-code without having written a single line of code in ABAP. When there are certain fields for which the data cannot be extracted directly, in that case some lines of codes are also to be written while creating the Infosets.