abap query
TRANSCRIPT
ABAP Query
Published by Team of SAP Consultants atSAPTOPJOBS
www.sap-topjobs.com
Copyright 2005@SAPTOPJOBS
All rights reserved. No part of this publication may be reproduced, stored in aretrieval system, or transmitted in any form, or by any means electronic ormechanical including photocopying, recording or any information storage andretrieval system without permission in writing from SAPTOPJOBS.
TABLE OF CONTENT
INTRODUCTION ..................................................................................................3Scenario 1.............................................................................................................41. Finding Database tables for creating queries.................................................42. Create a User group ....................................................................................193. Create an Infoset .........................................................................................274. Assign Infoset to User Group.......................................................................395. Create Query ...............................................................................................41Scenario 2...........................................................................................................641. Creating an Infoset ......................................................................................652. Assign Infoset to User group........................................................................863. Create a Query ............................................................................................884. Transporting Queries .................................................................................108
INTRODUCTION
In every project we come across situations where the client is not satisfied by thestandard SAP reports. In such situations most of the times functional consultantshave to be at the mercy of ABAPERS. This not only costs time but also a gooddeal of money for the client.
ABAP Query was a blessing in disguise for both functional SAP consultants aswell as end users of the company. Here, one could easily design various reportswithout any technical knowledge. Functional consultants will find this tool veryuseful and an added skill in today multi tasking environment.
We have attempted to bring you meat of ABAP query in this document. I am sureyou would find this very useful in your current job as a consultant or a end user.
Scenario 1
1. Finding Database tables for creating queries
We want to view the company code segment of the entire customer mastersin the company. Standard reports available do not give the desiredinformation. Therefore we feel the need to create an ABAP Query.
To create an ABAP query you need to know the database table where theinformation 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 isFD03
Go to the company code data
Position the cursor on the field Recon. account and press functionkey F1 on the key board to see the field help.
Click on Technical info
Thus you get the Transparent table name – KNB1
Here you have easily got the table.
Option 2
Sometimes the table name is not as easily available as was available inoption 1.
In the same transaction
Click on
Click on the field Name and now again press function key F1 onthe keyboard
Click on
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.
Click
Click
Click
Double click
Update the following:-
Click
Click down to find where customer table for general data appears
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à SQ01Queries
Click
Update the following:-
Click
Update the following:-
Click
Assign users to the user group. You need to assign the users of the particulardepartment to the user group.
Click on
You will update the relevant users who will be using these queries.
Click
Click on
Click
3. Create an Infoset
Click Environmentà Infosets
Update the following:-
Click
Click
Update the following:-
Click
Click
Click
Click
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 FieldGroup/data fields (right hand side).
Position the cursor on
Then position the cursor on
Click on Insert field(s) in field group
Click
Hold the Ctrl key on the keyboard and select other fields also
By clicking
Click
Click
Click to generate the infoset
The infoset is now ready to use in the query.
Click
4. Assign Infoset to User Group
Update the following:-
Click
Select
Click
Click
5. Create Query
Here we maintain the source fields which are to be updated with the data.
Click to select user group
Select
Click
Update the following:-
Click
Click
Click
Update the following:-
Click
Select
Click
Update the following:-
Click
Click
Update the following:-
Click
Click
Click
Double click
Click
Double click
Similarly double click other fields to select
Click
Update the following:-
Click
Click
Update the following:-
In the above you screen shot you see that the Customer text is being showing asCustomer number. We need to change this.
Click twice
Click
Click the field will open upChange it to Customer Name
Click on
Click
Click
Click
Click on
Click until you reach
Now you can execute this query
By selecting
Click
Scenario 2
In scenario 1 we saw a simple query, where in all information required wasavailable in a single table.
But that is not the case always. Information which we require is not available in asingle table and is scattered across in more than one table. In such as scenarioyou need to create a join between these tables through a common field betweenthese tables.
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 thetable KNA1 and the accounting information for the customer is available in thetable KNB1. These 2 tables can be joined based on the common field customernumber in them.
Let us proceed with creating a new query
1. Creating an Infoset
Update the following:-
Click
Update the following:-
Click
Click
Update the following:-
Click
Click
Click
Click
Click
Select
Click on Settingsà Settings
Click
Select
Now click
Click
Position the cursor on
Click Undo relationship
Click
Click
Now Update the following:-
Click
Click
Click
Click
Click
Click
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
Click until you will see
Select the following fields
Select
Click
Click
Click on
Click
Click
Click
2. Assign Infoset to User group
Click
Select
Click on
Click twice
3. Create a Query
Click Other user group
Click
Click
Click
Uncheck
Update the following:-
Click
Click
Update the following:-
Click
Select
Click
Select
Click
Click
Click
Update the following:-
Click
Click
Click
Click
Click twice
Click on
Click thrice
To execute a query
Select
And then Click
4. Transporting Queries
Click
Update the following:-
Click
Click
Click
Click