You are on page 1of 111

SAP Query www.sapficoconsultant.

com


2005 -2006 sapficoconsultant.com. All rights reserved. No part of this e-book
should be reproduced or transmitted in any form, or by any means, electronic or
mechanical including photocopying, recording or by any information storage
retrieval system without permission in writing from www.sapficoconsultant.com


SAP is a trademark of SAP AG, Neurottstrasse 16, 69190 Walldorf, Germany.

SAP AG is not the publisher of this e-book and is not responsible for it under any
aspect.

Warning and Disclaimer

This e-book is sold as is, without warranty of any kind, either express or implied.
While every precaution has been taken in the preparation of this e-book,
www.sapficoconsultant.com assumes no responsibility for errors or omissions.
Neither is any liability assumed for damages resulting from the use of the
information or instructions contained herein. It is further stated that the publisher
is not responsible for any damage or loss to your data or your equipment that
results directly or indirectly from your use of this e-book.




SAP Query www.sapficoconsultant.com
TABLE OF CONTENT

INTRODUCTION.............................................................................................................. 4
Scenario 1 ......................................................................................................................... 5
1. Finding Database tables for creating queries...................................................... 5
2. Create a User group ..............................................................................................19
3. Create an Infoset....................................................................................................28
4. Assign Infoset to User Group ...............................................................................40
5. Create Query...........................................................................................................42
Scenario 2 .......................................................................................................................68
1. Creating an Infoset.................................................................................................69
2. Assign Infoset to User group ................................................................................90
3. Create a Query.......................................................................................................91
SAP Query www.sapficoconsultant.com
INTRODUCTION

SAP Query is a very powerful tool in SAP to get reports quickly without any
programming knowledge. Thus an SAP consultant does not have to depend on
an ABAP programmer to get a report developed.

SAP Query typically can handle only simple report requirements.
All data required by a user for a report can be read from various tables.
How do you find a table in SAP where the relevant information is available?
We have explained how to go about finding the relevant tables.

We have covered two scenarios for creating SAP Query: -
1
st
scenario: All information is available in a single table. This kind of query is a
very simple query.

2
nd
scenario: Information required is spread in 2 different tables. Thus you need
to create a join between the 2 tables using a common field.


Let us get going then.
SAP Query www.sapficoconsultant.com
Scenario 1

1. Finding Database tables for creating queries

We want to view the accounting data (company code segment) of the all the
customer masters in the company. Standard reports available do not give the
desired information. Therefore we feel the need to create an SAP Query.

To create an SAP query you need to know the database table where the
information exists.

How can that be obtained?

Option 1

We want to see the company code information of a customer.
Use the relevant transaction code to see the information. In this case it is
FD03

Go to the company code data
SAP Query www.sapficoconsultant.com



Position the cursor on the field Recon. account and press function
key F1 on the key board to see the field help.

SAP Query www.sapficoconsultant.com



Click on Technical info

SAP Query www.sapficoconsultant.com



Thus you get the Transparent table name KNB1

Here you have easily got the table.


Option 2

Sometimes the table name is not easily available as was available in option
1.


In the same transaction close all the help screens.



Click on

SAP Query www.sapficoconsultant.com


Click on the field Name and now again press function key F1 on the
keyboard

SAP Query www.sapficoconsultant.com


Click on

SAP Query www.sapficoconsultant.com


In the above screen transparent table is not visible.

Note down the field name NAME1

In another session type in transaction code SE90 in the command field.

SAP Query www.sapficoconsultant.com


Click

SAP Query www.sapficoconsultant.com


Click


SAP Query www.sapficoconsultant.com


Click

SAP Query www.sapficoconsultant.com



Double click

SAP Query www.sapficoconsultant.com





















SAP Query www.sapficoconsultant.com
Update the following:-



Click


SAP Query www.sapficoconsultant.com


Click down to find where customer table for general data appears

SAP Query www.sapficoconsultant.com




We will use the table KNA1 for General data in Customer Master.







2. Create a User group

Use the following path:-

SAP menu Tools ABAP Workbench Utilities SAP Query SQ01
Queries

SAP Query www.sapficoconsultant.com





Click


SAP Query www.sapficoconsultant.com



SAP Query www.sapficoconsultant.com

Update the following:-



Click



SAP Query www.sapficoconsultant.com



Update the following:-



Click

Update the following:-



Click on


SAP Query www.sapficoconsultant.com

Click



Click on



Click

Assign users to the user group. You need to assign the users of the particular
department to the user group.

Click on

SAP Query www.sapficoconsultant.com



You will update the relevant users who will be using these queries.

SAP Query www.sapficoconsultant.com


Click

SAP Query www.sapficoconsultant.com


Click on




Click





















SAP Query www.sapficoconsultant.com


3. Create an Infoset

Click Environment Infosets



SAP Query www.sapficoconsultant.com


SAP Query www.sapficoconsultant.com
Update the following:-



Click

SAP Query www.sapficoconsultant.com



Click
SAP Query www.sapficoconsultant.com

Update the following:-



Click



Click

SAP Query www.sapficoconsultant.com



Click

SAP Query www.sapficoconsultant.com



Click

SAP Query www.sapficoconsultant.com



You will notice in the above screen that some fields have T above them



This means that in this field text is also available.

Now we need to select fields from the table (left hand side) to the Field
Group/data fields (right hand side).

Position the cursor on

Then position the cursor on



SAP Query www.sapficoconsultant.com


Click on Insert field(s) in field group


SAP Query www.sapficoconsultant.com


Click

Hold the Ctrl key on the keyboard and select other fields also



By clicking








Click


SAP Query www.sapficoconsultant.com



Click



Click on

SAP Query www.sapficoconsultant.com


Here you can save to the existing request or create a new request.

We will save to the same request.

Click


Click to generate the infoset

The infoset is now ready to use in the query.

Click


SAP Query www.sapficoconsultant.com



4. Assign Infoset to User Group


Update the following:-



Click


SAP Query www.sapficoconsultant.com



Select

Click


Click















SAP Query www.sapficoconsultant.com
5. Create Query

Here we maintain the source fields which are to be updated with the data.




Click to select user group
SAP Query www.sapficoconsultant.com


Select

Click


SAP Query www.sapficoconsultant.com


Update the following:-



Click

SAP Query www.sapficoconsultant.com


Click


SAP Query www.sapficoconsultant.com














SAP Query www.sapficoconsultant.com

Update the following:-



Click

SAP Query www.sapficoconsultant.com



Select

Click


SAP Query www.sapficoconsultant.com










SAP Query www.sapficoconsultant.com

Update the following:-



Click

SAP Query www.sapficoconsultant.com


SAP Query www.sapficoconsultant.com


Click

SAP Query www.sapficoconsultant.com















SAP Query www.sapficoconsultant.com
Update the following:-




Click

Click

SAP Query www.sapficoconsultant.com



Click

SAP Query www.sapficoconsultant.com



Double click

SAP Query www.sapficoconsultant.com


Click
SAP Query www.sapficoconsultant.com



Double click

Similarly double click other fields to select

SAP Query www.sapficoconsultant.com

Click

SAP Query www.sapficoconsultant.com


SAP Query www.sapficoconsultant.com
Update the following:-



Click

SAP Query www.sapficoconsultant.com


Click












SAP Query www.sapficoconsultant.com





Update the following:-




Click



In the above screen shot you see that the Customer text is being showing as
Customer number. We need to change this.

Click twice

SAP Query www.sapficoconsultant.com


Click


SAP Query www.sapficoconsultant.com


Click the field will open up
Change it to Customer Name

SAP Query www.sapficoconsultant.com



Click on





Click

SAP Query www.sapficoconsultant.com


Click




Click twice

Click on

Click until you reach

SAP Query www.sapficoconsultant.com


Now you can execute this query

By selecting



Click



Scenario 2

In scenario 1 we saw a simple query, where in all information required was
available in a single table.

But that is not the case always. Information which we require is not available in a
single table and is scattered across in more than one table. In such a scenario
you need to create a join between these tables through a common field between
these tables.

SAP Query www.sapficoconsultant.com
In this scenario we want to have information of the customer master with name,
address and also the accounting information.

We have seen earlier that the customer address information is available in the
table KNA1 and the accounting information for the customer is available in the
table KNB1. These 2 tables can be joined based on the common field customer
number in them.


Let us proceed with creating a new query

1. Creating an Infoset



SAP Query www.sapficoconsultant.com
Update the following:-



Click

SAP Query www.sapficoconsultant.com

SAP Query www.sapficoconsultant.com


Update the following:-



Click



SAP Query www.sapficoconsultant.com
Click



Update the following:-



Click



Click



SAP Query www.sapficoconsultant.com


Click





Click

Click

SAP Query www.sapficoconsultant.com


Select




Click on Settings Settings

SAP Query www.sapficoconsultant.com
Click






Select


Now click


SAP Query www.sapficoconsultant.com



Click

SAP Query www.sapficoconsultant.com


Position the cursor on

Click Undo relationship


SAP Query www.sapficoconsultant.com


Click

Click

SAP Query www.sapficoconsultant.com


Now Update the following:-

SAP Query www.sapficoconsultant.com


Click

SAP Query www.sapficoconsultant.com


Click

SAP Query www.sapficoconsultant.com




Click

SAP Query www.sapficoconsultant.com




Click

SAP Query www.sapficoconsultant.com


Click

Click


SAP Query www.sapficoconsultant.com
Click

Thereafter select all the fields you want to move on the right side.

Press the Ctrl button to select more than one field.



Click


Click

SAP Query www.sapficoconsultant.com



Click until you will see

Select the following fields

SAP Query www.sapficoconsultant.com


Select




Click

SAP Query www.sapficoconsultant.com
Click




Click on

Click

Click


Click








SAP Query www.sapficoconsultant.com
2. Assign Infoset to User group



Click




SAP Query www.sapficoconsultant.com



Select

Click


Click twice




3. Create a Query


Click Other user group

SAP Query www.sapficoconsultant.com



Click

Click




Click
SAP Query www.sapficoconsultant.com







Uncheck

SAP Query www.sapficoconsultant.com



Update the following:-




Click



SAP Query www.sapficoconsultant.com



Double click

SAP Query www.sapficoconsultant.com


Update the following:-

SAP Query www.sapficoconsultant.com



Click

SAP Query www.sapficoconsultant.com


Select



Click

SAP Query www.sapficoconsultant.com


Select

SAP Query www.sapficoconsultant.com


Click

SAP Query www.sapficoconsultant.com




Click

SAP Query www.sapficoconsultant.com


SAP Query www.sapficoconsultant.com


Click

SAP Query www.sapficoconsultant.com


Update the following:-

SAP Query www.sapficoconsultant.com


Click

SAP Query www.sapficoconsultant.com


SAP Query www.sapficoconsultant.com



Click

SAP Query www.sapficoconsultant.com


SAP Query www.sapficoconsultant.com


Click




SAP Query www.sapficoconsultant.com




Click

SAP Query www.sapficoconsultant.com


Click twice

Click on

Click thrice




To execute a query

Select


And then Click

Congrats. You are now able to create a report (Query) on your own.

Create as many queries as you want. All the best.

You might also like