SAP QUERY
By:
MANJARI SINGH
Contents
1. Query
2. Types of Report
3. Components of SAP Query
4. Query Area
5. Tcodes for SAP Query
6. User Group
7. Infoset
8. SAP Query
9. Field mandatory on selection screen
What is Query?
• Many times a need arises for SAP Users and Functional
Consultants to generate quick reports without getting any
ABAP coding done .
• The time taken to complete the coding in development,
transport and test it in QA system and then transport to
production – is sometimes too long.
• In such cases, SAP query is a tool provided by SAP for
generating these kinds of reports.
Purpose :
• The SAP Query application is used to create reports .
• It has been designed for users with little or no knowledge of the SAP
programming language ABAP.
• SAP Query offers users a broad range of ways to define reports .
• In a query, you are able to define three different simple types of reports :
1. Basic lists
2. Statistics list
3. Ranked lists
• The outputs can include lists on screens in table format, ALV grids,
downloadable spreadsheets, and downloadable flat files. The internal report
generator creates an ABAP program corresponding to the definition of the list.
1. Basic lists It is a simple report .The data is displayed as it
appears in the data source.
Basic List
Single List Multiple line
2. Statistics list They are reports with statistical
functions like average.
The output of the data in statistics is in a
compressed form.
3. Ranked lists These are used for analytical reports.
When you choose a numeric value as the only
sort criterion in a statistic, the result is
practically a ranked list. With statistics,
however, you cannot restrict the number of
items that are displayed.
Features:
The SAP Query comprises four components:
Ø Queries
Ø InfoSets
Ø User Groups
Ø Translation/Query
QUERIES
• The queries component is used by end user to maintain queries .
• One can create ,change and execute queries.
Transaction : SQ01
INFOSETS
An infoset describes which field of a data source can be reported in a query .
Advantage:
• By creating infoset and assigning them to roles or user groups, the system administrator
determines the range of reports that the individual application departments or end-
users are able to generate using the SAP Query.
• End-users are able to work only with those InfoSets that are relevant to their particular
area, as designated by the role or user group that they are assigned to.
Transaction : SQ02
USER GROUP
• User working in the same application are assigned to a same user group.
• It does not matter who defined the query in a user group.
• Every user assigned to user group can execute the query .
Transaction : SQ03
TRANSALATION/QUERY COMPONENT
• A lot of text are generated while creating Query ,Infoset and user groups.
• These text are generated in the language that we chose when we log on to SAP system
• We can compare the text/languages using this component.
Transaction : SQ07
QUERY AREA
A query area contains a set of query objects (queries, InfoSets, and user groups) that are
discrete and consistent.
There are the following query areas:
Standard area
Global area
Standard Area
1.Client specific
2.Query objects are not attached to the Workbench Organizer
Advantage :-End users can develop queries (ad-hoc reports) in their own client that are not
meant for use in the rest of the system.
Global Area
1. Cross client
2. Query objects are attached to workbench organizer
Advantage:-The global query area is well suited for centrally developing queries meant for
use and distribution throughout the system.
The whole process comprises of 3 steps:
-> Creation User group
-> Creation Infoset
-> Creation query
The transaction codes associated with ABAP query are:
• User Group – SQ03
• Infoset – SQ02
• Query – SQ01
USER GROUP
• Technical definition of “User group” is a collection of SAP users grouped together.
• A user’s assignment to a user group determines which query user can execute or
maintain. Additionally it designates which Infoset user can access .
Steps to create new User group :
1) Go to transaction – SQ03.
2) Type user group name and select create
Type the name of the user group ZUSER ,”TEST FOR USER GROUP” and click save
Give the package name, here I have saved in local object
Select the Assign user and Infoset button .
Type the SAP user ID’s of any user you want to include in test group
After entering the user name , SAVE
INFOSET
Creating an Infosets
• An InfoSet describes which fields of a data source can be reported on in queries.
• InfoSets are assigned to user groups.
Steps to create an Infoset:
• Go to transaction SQ02.
• Type the Infoset name “ZMYINFOTEST” and select CREATE.
2. Type the name of the Infoset” TEST FOR INFOSET”.
Choose the data source and press ok button.
Authorizations
End-users, system administrators, and translators must all be assigned the appropriate
authorizations allowing them to work with the SAP Query.
• You will be provided with a screen as shown below.
INSERT TABLE BUTTON
• Select insert table icon in application tool bar.
• A popup will appear, give the table name to be inserted and select OK button.
Give the table name and select OK.
You will be provided with the screen shown below
For maintaining the Infoset ,click on the infoset button.
A pop-up opens asking what fields should be there in field group .
Select radio button “Create empty field group” and click ‘OK’.
Two empty field groups got created .In Left pane ,we find the list of fields in both the
table LFA1 and LFB1.
Drag and drop the fields from the left pane on to the field groups.
GENERATE BUTTON
Next, you need to generate the InfoSet by selecting the Generate button (the red ball) from
the application toolbar.
A message appears in the status bar saying that the InfoSet ZMYINFOSET generated.
-> Go back to the main screen of SQ02 by clicking Back Button on standard tool bar.
-> Click on Role/User Group Assignment button to assign the infoset to a specific user group.
SAP QUERY
STEP BY STEP PROCEDURE in creating a simple list using SAP Query
1. Go to transaction SQ01.
2.Give ZTEST_QUERY as Query Name and Click on Create button.
->A hit list opens assigned to the user group (ZUSER).
->Select ZMYINFOSET and click Ok.
This moves to the first screen of creation of query.
-> Type the title (mandatory), notes and specify the number of lines to be displayed
in a page. Next Screen Button
To navigate to the next screen in the SAP query-creation process, select the next screen
button from the application toolbar.
Select the field groups that are to be used in our query
Again go to next screen[F6] to select the list of fields required in Query. Fields include
both selection screen and output fields and click basic list.
Click on the next screen to specify which of the field are to be used in selection screen and
specify the sequence in which selection to appear in selection screen.
After providing all the above options you can save the query and execute it .
How to make a field mandatory on selection screen:
Go to the info set of the query.
SQ02 -> Enter the infoset name -> click on 'Change'
Go to the 'Selections' tab.
Selection
There you will find all the selection screen parameters. click on the create button.
Give a name eg : NAME
Give description ,selection text.
In format FOR give the technical name
Extras make it oOBLIGATORY
SAVE
If you try to execute leaving name as blank ,it will give you error message.
THANK YOU