wiki sap query

14
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. The SAP Query comprises five components: Queries - SQ01 InfoSet Query - InfoSets - SQ02 User Groups - SQ03 Translation/Query - SQ07 Query Areas A query area contains a set of query objects (queries, Infoset, and user groups) that are discrete and consistent. There are the following query areas: Standard area Global area Standard Area

Upload: masoomjajoo

Post on 12-Aug-2015

101 views

Category:

Technology


5 download

TRANSCRIPT

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.

The SAP Query comprises five components:

Queries - SQ01 InfoSet Query - InfoSets - SQ02 User Groups - SQ03 Translation/Query - SQ07

Query Areas

A query area contains a set of query objects (queries, Infoset, 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.

Steps to create a Query

Transaction – SQ02 (Infoset creation)

STEP 1:

Open Transaction SQ02. Create Infoset

STEP-2

Assign Data sources

1. Name 2. 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 to see Authorization Groups

3. 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. Reading tables directly: Is used when Query is prepared for retrieving data

from one table. 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. Declaration in data section of the program will help the query to select

Create a infoset or functional area

SQ02

Assignment of user group to

infosetSQ03

Creation of query based on infoset

SQ01

the elements of data to be retrieved from database. As per the logic, data is validated, processed. The selection screen can be prepared in Query and data is retrieved for output.

4. Options No Automatic Text Recognition Fixed Point Arithmetic

In example here, we have selected Table join using basis table : SPFLI

The following screen will appear.

STEP-3

To join a table with this SPFLI table , Click on the button as shown in image below:

Add table SFLIGHT here.

The tables will automatically get joined to each other. Click on Infoset.

STEP-4

We will create empty field groups and Add fields as we want.

The two filed groups will be created corresponding to two tables we selected before. i. e SPFLI and SFLIGHT.

STEP-5

1. Select a field group.2. Select a field, right click and ad field to field group.

Repeat this step for as many field s you want in a field group. Also do same for second field group.

STEP-6

Click Generate Button.

The Infoset ZMJ_INFOSET2 is generated.

Transaction – SQ03 (User group Creation)

STEP-1: Execute transaction SQ03 and create a USERGROUP

The USER GROUP will be saved.

STEP-2: Now on same transaction SQ03 , Mention the InfoSet as shown on screen.

Click assign users and InfoSets to a user group created.

STEP-3: On the next screen assign the users for the user group to whom you want to give authorizations. Click Change authorizations to change the authorization.

Assign Infoset to users selected

STEP-4:

Select InfoSets to be assigns to user selected on previous screen.

Save user group.

The user group will be saved.

Transaction – SQ01 (Query Creation)

STEP 1: Execute transaction SQ01 to create a query.

Write a query name and create.

Select the InfoSet into which the query is to be created.

STEP 2:

Fill details and click Basic List.

Select the keys. You will see the data creating in Yellow circle.

Click test.

This is the output of SAP query made by us.

Creating transaction using ABAP Query

STEP 1:

Transaction SE93.

STEP 2:

STEP 3:

Execute

OUTPUT :