Saturday 21 May 2016

Ad-hoc Query

Ad-hoc Query

Most of the reporting needs of an organization can be addressed through Adhoc Queries. 
They provide 3 different kinds of reports:

  • Basic List : For simple reporting
  • Statistics : Reports with statistical functions such as percentages, etc.
  • Ranked list : for easy analysis of the reports

Queries are the actual reports that an end-user can run within SAP, these can be set up in Ad Hoc Query.


This document will cover below area

·  Creating Query area

·  Creating  User Group 

·  Creating  Infoset 

·  Creating  Adhoc query


Query Areas define whether the report is available cross client (Global Area) or only in the client that it is built (Standard Area). If SAP is set to Global Area, then it is not possible to see any reports built in the Standard Area and vice versa. 

Infosets define which infotypes and which fields within those infotypes you can report on

User Groups define which groups of end users can see different infosets

Steps needs to perform for creating ad-hoc query

SQ01 : It is used to report the infoset data by creating ad-hoc query.

SQ02 : Here we will include all of our tables or infotypes (e.g. PA/OM) that will provide us data for our queries.

SQ03 : To create a new user group go to transaction SQ03 and create a new user group and assign users to that user group.



Go to the transaction SQ03





Select Query areas under the menu item Environment. Select the radio button ‘Global Area’


Create a user group which will specify the users who will be authorized to run the query. It will always be associated with the functional area


Give short meaningful description & Save


Go to the T-code SQ02 to create the infoset


Give a name to the infoset and click on create.


Provide the Infoset attributes as show below. Here we are using PNP LDB in the example.



A window with the provision to choose all required infotypes pops up(here PA infotypes as PNP LDB is used). Open the node ‘Empl. Contract data’ as in our example we want to report some personal and org related data of the employees





Select the infotypes 0001 and 0002 by selecting the check boxes against them.



The following screen of the created infoset appears as below. Click on save and then Generate the infoset



Go to the main screen and click on Role/User group assignment








Select the assigned user group that we created earlier i.e. ZDEMO_LND and save it.

Now go to the transaction SQ01 to create the Ad-hoc query to report the data from the infoset.

Give a name for the Query (here ZDEMO_QRY) and click on create


Choose our required infoset name which will navigate to below screen.

Provide the query title and other info as shown below. Save and go back to main screen.

Click on Infoset query button below.The Infoset query window opens as below.






Upon expanding the nodes at the left, choose appropriate fields for selection criteria and also for display in the report output




From the menu item Query, save the query with a name

Go back and Execute the query using F8