This action might not be possible to undo. Are you sure you want to continue?
By Suraj Kumar Pabbathi SAP Query is SAP’s tool to define and execute once own reports without knowing ABAP programming language. Let us see the key topics to explore SAP Query. Topic # 1 Topic What is Query? Purpose of Query. 2 3 4 Advantages of Query Infosets/UserGroups/Query in Detail Practical session covering important working models - I Practical session covering important models-II Various Lists and Background Scheduling In this document we shall cover Topic#1. What is SAP query and why do we need queries? Many times a need arises for SAP Users and Functional Consultants to generate quick reports without getting any ABAP coding done – 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 not already contained in the default. 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 and create different types of reports such as basic lists, statistics, and ranked lists. These 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.
Features: The SAP Query comprises five components: Queries InfoSet Query
InfoSets User Groups Translation/Query Classic reporting- the creation of lists, statistics and ranked lists- are covered by the InfoSet Query and Queries components. Other components’ range of functions cover the maintenance of InfoSets, the administration of user groups and also the translation of texts created in the SAP Query. All data required by a user for a report can be read from various tables. To define a report, you first have to enter individual texts, such as titles, and select the fields and options, which determine the report layout. In the WYSIWYG (What You See Is What You Get) mode, you can edit the lists using Drag & Drop and various toolbars. Overview: The following sections describes the individual SAP Query components and provides general information about query areas, transport and authorizations Menu Path à SAP Query à Queries à SAP Query à InfoSets Used For Maintaining Queries Maintaining InfoSets Transaction Code SQ01 SQ02 SQ03 SQ07
à SAP Query à User Groups Maintaining User Groups à Translation à Query Query Components The Queries component is used by end users to maintain queries. You can carry out the following tasks: Execute Queries and Generate Lists Define Queries Change Queries Infosets Components Language Comparision
InfoSets are special views of data sources. An InfoSet describes which fields of a data source can be reported on in queries. InfoSets are assigned to user groups. 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. Eg: Vendor master data can be important in purchasing as well as in accountancy. The relevant InfoSet is assigned to both roles/user groups. This means that queries based on this InfoSet can be copied and executed by both groups. User Groups Components
1. The User Groups component is used to maintain user groups. The system administrator uses it to set
up the work environment for end-users. Every user assigned to the user group is able to execute the query. 3. Users are not allowed to modify queries from other user groups, although they may, under certain circumstances, copy and execute 2.
Translation/Query Component A great deal of text is generated when defining queries, InfoSets, and user groups. The SAP Query displays these texts in the language that you chose when you logged on to the SAP system. You can compare the text languages using the component Translation/Query. A related text in one or more additional languages is made available for each of the texts created when defining the query. Query Areas 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. Authorizations End-users, system administrators, and translators must all be assigned the appropriate authorizations allowing them to work with the SAP Query. In order to give individual users targeted, specific rights, the following options are available: Roles/user groups Authorizations Steps to create a Query Step 1 2 3 Description Create a infoset or functional area Assignment of user group to infoset Creation of query based on infoset TCODE SQ02 SQ03 SQ01
Tools for Queries The following are the tools to manage, create and change queries. Infoset Query Queries
Working with Infosets, User Groups, Query in detail
By Suraj Kumar Pabbathi, YASH Technologies In this document we shall cover Topic#2. For topic#1, click here. INCLUDEPICTURE "http://www.saptechnical.com/Tutorials/SAPQuery/Part2/Page1.15.gif" \* MERGEFORMATINET
INCLUDEPICTURE "http://www.saptechnical.com/Tutorials/SAPQuery/Part2/Page1.16.gif" \*
as designated by the role or user group that they are assigned to. Creating and changing Infosets Creating Infosets – Prerequisites Assign Data sources Infoset Display/Change Definition of field groups . End-users are able to work only with those InfoSets that are relevant to their particular area.MERGEFORMATINET Infosets Components InfoSets are special views of data sources. InfoSets are assigned to user groups. Eg: Vendor master data can be important in purchasing as well as in accountancy. The relevant InfoSet is assigned to both roles/user groups. This means that queries based on this InfoSet can be copied and executed by both groups. An InfoSet describes which fields of a data source can be reported on in queries.
Logical databases: Is used when Query is prepared for retrieving data based on a Logical database (LDB) Using programs to retrieve data: Here a program can be written with own logic.) Do you need parameters and selection criteria? (Parameters and selection criteria appear on the selection screens of queries that are created using the InfoSet). Which data source corresponds to the requirements? For example: Material reports in Materials Management Document reports in Financial Accounting Which fields do you need to include in the InfoSet? Do you need additional information which is not available in the data source? (This means you are going to have to connect additional tables and the definitions of additional fields. 2.Obtaining additional information Creating Selections Further Codes Application Specific Enhancements Creating Infosets – Prerequisites The following questions help in meeting the prerequisites of creating an infoset. 4. Do you need to include any particular measures such as access protection? Do you need to be able to change the long texts and headers for the selected fields? Assign Data sources 1. Declaration in data section of the program will help the query to select the elements of data to be retrieved from database. Reading tables directly: Is used when Query is prepared for retrieving data from one table. Name Authorization group: This means that only users authorized to execute programs from this authorization group are able to execute these queries. . Use Tcode: AUTH_DISPLAY_OBJECTS Choose Data Source: Table join using a table: Is used when Query is prepared for retrieving data from more than one database tables having relationships. 3.
Sequential datasets 4. data is validated.As per the logic. Fields must be assigned to a field group before they can be used in queries. processed.Eg: PNP . The selection screen can be prepared in Query and data is retrieved for output. Include all table fields Include key fields Create empty field groups Note: Logical Database having more than 4 structures has different way of creating field groups. Assigning additional tables Creating additional fields Creating additional Structures Extras Selections Further Code Application Specific Enhancements Definition of field groups A field group combines related fields together into a meaningful unit. Options No Automatic Text Recognition Fixed Point Arithmetic Display/Change Infoset The InfoSet display allows you to examine or change the structure of the InfoSet.
Every user assigned to the user group is able to execute the query. The system administrator uses it to set up the work environment for end-users. copy and execute . under certain circumstances.User Groups Components The User Groups component is used to maintain user groups. Users are not allowed to modify queries from other user groups. although they may.
Creating infosets or functional areas Tcode-SQ02 .1.
To create user groups and assign to infosets Tcode-SQ03 .2.
To create a query Tcode-SQ01 .3.
Steps to create selection criteria to the query Tcode-SQ01 .
.SAP Query Step-by-step procedure in configuring SAP Query SAP R/3 Query tools (SAP Query) are based on the following four main components: • • • • Query Areas Query Groups InfoSets Administrative Decisions (Company-specific) Configuration of the Query tools is done in the following manner: • • • • Create Query Groups Assign Users to Query Groups Create InfoSets Assign each InfoSet to a Query Group. Create Query Groups • Go to Transaction SQ03.
• Ensure that you are in the correct SAP Query area by navigating to Environment à Query Areas • • Select the “Standard Area (Client-specific). Now in the main screen. enter the name of the Query Group in the User Group field and click on CREATE .
. Assign Users to Query Groups • Click on the “Assign Users and InfoSets” button • Enter the SAP User-Ids of all the users you wish to include in the test group. • User Group ZSAPTECH_GRP is created.• Enter the description of the User Group in the next popup that appears.
Click on SAVE to save your entries. Create InfoSets • • Go to transaction SQ02 Ensure that you are in the correct SAP Query area by navigating to Environment à Query Areas • Enter the name of the InfoSet you wish to create and click on CREATE. .
We have used the LDB F1S (Flight bookings related) for our demo purpose.• Enter the title and the logical database on the popup screen that appears. .
the left side of the screen shows the tables and the fields. Now we need to assign fields to the field groups.• Change InfoSet screen appears. Select the field group on the right side and then drag and drop the fields from the left side to this field group. • Expand the tree on the left hand side to view the fields in each table. These field groups will display in the SAP Query tool during reporting. • • . As seen on the screen. The right side displays the field groups. Please note that only the fields that are included here will be available for field selection in the SAP Query Tool that uses this infoSet as a data source.
• When Attach each InfoSet to a Query Group • • Go to transaction SQ02 Enter the InfoSet name created above and click on “User Group Assignment” button. . click on SAVE. • Now generate the InfoSet by clicking on GENERATE.all the required fields are added.
The title bar shows you the query group you are currently in. Go to Transaction SQ01. 2. SAP Query Step-by-step procedure in creating a simple list using SAP Query 1. Ensure that you are in the correct SAP Query area by navigating to Environment à Query Areas .• Select the query group “ZSAPTECH_GRP” from the above list and click on SAVE. 3.
The InfoSets of the user group ZSAPTECH_GRP is displayed.4. 5. 6. . In the field “Query”. Select the InfoSet ZSAPTECH_IS and click ENTER. enter the name of the query you want to create and press CREATE.
on . Click “Next screen” button as shown in the above screenshot. Enter the title and any other notes that are required.7.
8. We can select any particular fields we would like to have in our report. 9. We can select the field groups that need to be listed in the report. All the fields in the selected Field groups appear in this screen. Click on Next screen. 10. . All the field groups available with the InfoSet are listed above.
. Click on Next screen.11.
13. we can select the fields to appear on the selection screen during execution of the report. specify the line number and sequence number as you would like to appear on the report. In this screen. Click on the “Basic List” button to create a SAP Basic list query. You can also use this screen to indicate sort order. 14. totals and counts (as . For each field.12.
here also the selection-screen appears. As shown above. Click on SAVE.necessary). 15. . Click on EXECUTE button to execute the report. 16. the line structure would display the appearance of fields on the selectionscreen. As it is seen on normal reports.
g. Using table join Directly reading from tables Using logical databases (LDB) e. 3. 2. 4. Capgemini There are 4 different ways to write SAP queries – depending on the approach of data retrieval strategy: 1. PNP Using some programs .Building an SAP Query using ABAP Code By Jayanta Bej.
1. Press ‘Create’ button.Here in this document. . Create InfoSet by using t-code SQ02: 2. we’ll demonstrate building SAP query using 2nd method (Direct read of table).
Press enter. Press ‘Code’. .Press enter. 3.
seatsocc TYPE s_seatsocc. 4. TABLES: scarr. fldate TYPE s_date. TYPE-POOLS: slis. i_flight TYPE STANDARD TABLE OF ty_flight INITIAL SIZE 0. i_fldcat TYPE slis_t_fieldcat_alv. currcode TYPE s_currcode. * Type for taking data from tables SFLIGHT and SCARR TYPES: BEGIN OF ty_flight. wa_fldcat TYPE slis_fieldcat_alv. carrid TYPE s_carr_id. * Internal table and work area declaration DATA: wa_flight TYPE ty_flight. carrname TYPE s_carrname. END OF ty_flight. . Write the following code in this section.3. seatsmax TYPE s_seatsmax. connid TYPE s_conn_id. Select the ‘DATA’ coding section.
. * Retrieve data from tables SFLIGHT and SCARR SELECT m1~carrid m1~connid m1~fldate m1~seatsmax m1~seatsocc m2~carrname m2~currcode INTO TABLE i_flight FROM sflight AS m1 INNER JOIN scarr AS m2 ON m1~carrid = m2~carrid. CLEAR: wa_flight.5. * Populate the field catalogs wa_fldcat-col_pos = 1. Now go to START-OF-SELECTION section And write the following code in START-OF-SELECTION section to display a few field data in ALV grid display report format.
wa_fldcat-seltext_l = 'Flight connection Id'. wa_fldcat-seltext_l = 'Airline carrier ID'. CLEAR: wa_fldcat. CLEAR: wa_fldcat. wa_fldcat-seltext_l = 'Airline name'. APPEND wa_fldcat TO i_fldcat. wa_fldcat-col_pos = 4. wa_fldcat-seltext_l = 'Flight date'. CLEAR: wa_fldcat. CLEAR: wa_fldcat. wa_fldcat-fieldname = 'FLDATE'. 6. * ALV grid display report CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING it_fieldcat = i_fldcat TABLES t_outtab = i_flight EXCEPTIONS program_error = 1 OTHERS = 2. APPEND wa_fldcat TO i_fldcat. wa_fldcat-col_pos = 2. EXIT. CLEAR: wa_fldcat. wa_fldcat-col_pos = 7. IF sy-subrc <> 0. wa_fldcat-col_pos = 5. . APPEND wa_fldcat TO i_fldcat. Now create a user group. wa_fldcat-col_pos = 6. CLEAR: wa_fldcat.wa_fldcat-fieldname = 'CARRID'. APPEND wa_fldcat TO i_fldcat. APPEND wa_fldcat TO i_fldcat. wa_fldcat-seltext_l = 'Local currency of airline'. wa_fldcat-fieldname = 'CURRCODE'. APPEND wa_fldcat TO i_fldcat. ENDIF. wa_fldcat-col_pos = 3. wa_fldcat-fieldname = 'CONNID'. 7. wa_fldcat-seltext_l = 'Maximum capacity'. Generate the InfoSet. APPEND wa_fldcat TO i_fldcat. wa_fldcat-seltext_l = 'Occupied seats'. wa_fldcat-fieldname = 'SEATSOCC'. CLEAR: wa_fldcat. wa_fldcat-fieldname = 'SEATSMAX'. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. wa_fldcat-fieldname = 'CARRNAME'.
. I’ve assigned two users in my user group.8. Now assign the user group ZUGRP_BEJ to the InfoSet ZINFOSET_BEJ.
Now create the query. . 9.Save it.
Now execute the query from SQ01.10. . The following selection screen will appear where we need to put the flight date.
2008 and execute the query. By using the standard program ‘RSAQR3TR’ By using the transport option available on the application bar in Transactions SQ02 or SQ03. 2.Enter the flight date as 11. Transport of SAP Query objects By Shiva Kumar Tirumalasetty. we’ll get the following ALV grid display report. From Transaction SQ02/SQ03->Environment->Transports: . Deloitte Consulting India Pvt Ltd ABAP Queries can be transported to different clients by the following two ways: 1.06.
On the next screen. . all the options come up for transporting the queries. The transport action is performed based on the radio button selected on the screen.
By using the standard program ‘RSAQR3TR’: Execute the standard program RSAQR3TR On the next screen. The transport action is performed based on the radio button selected on the screen. all the options come up for transporting the queries. 4. 2. . The User Group is to be transported first. followed by the Infoset and then the Queries. User Group transport Infoset transport Infoset and Query transport Queries transport The transports are to be made in the specified order.The transports are to be made in the following order: 1. 3.
Create transaction for SAP-Query By Aswani Bharath. Dell Services 1) Open transaction SE93 .Once the query is transported or uploaded in the destination system in the method specified above. the same can be used there for displaying the data fetched from the database.
2) Put object name . Transaction with parameter.sort text for your transaction 3) Choose radio button 5. 4) Default value for transaction ‘START_REPORT’ 5) In bellow default value section insert default value .
SREPOVARI-REPORTTYPE = AQ "Parameter indicating Abap Query D_SREPOVARI-REPORT = ZY_CS_ALLSLS "Query User group D_SREPOVARI-EXTDREPORT= ZY_SLS_MST_001 "Query name 6) Save the transaction. .
.8) Execute the transaction.
This action might not be possible to undo. Are you sure you want to continue?