Download - Abap Query
![Page 1: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/1.jpg)
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.
![Page 2: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/2.jpg)
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
![Page 3: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/3.jpg)
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.
![Page 4: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/4.jpg)
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
![Page 5: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/5.jpg)
Position the cursor on the field Recon. account and press functionkey F1 on the key board to see the field help.
![Page 6: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/6.jpg)
Click on Technical info
![Page 7: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/7.jpg)
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
![Page 8: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/8.jpg)
Click on
![Page 9: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/9.jpg)
Click on the field Name and now again press function key F1 onthe keyboard
![Page 10: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/10.jpg)
Click on
![Page 11: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/11.jpg)
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.
![Page 12: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/12.jpg)
Click
![Page 13: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/13.jpg)
Click
Click
![Page 14: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/14.jpg)
Double click
![Page 15: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/15.jpg)
Update the following:-
![Page 16: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/16.jpg)
Click
![Page 17: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/17.jpg)
Click down to find where customer table for general data appears
![Page 18: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/18.jpg)
We will use the table KNA1 for General data in Customer Master.
![Page 19: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/19.jpg)
2. Create a User group
Use the following path:-
SAP menu à Toolsà ABAP Workbenchà Utilitiesà SAP Queryà SQ01Queries
Click
![Page 20: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/20.jpg)
![Page 21: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/21.jpg)
Update the following:-
![Page 22: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/22.jpg)
Click
![Page 23: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/23.jpg)
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
![Page 24: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/24.jpg)
You will update the relevant users who will be using these queries.
![Page 25: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/25.jpg)
Click
![Page 26: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/26.jpg)
Click on
Click
![Page 27: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/27.jpg)
3. Create an Infoset
Click Environmentà Infosets
![Page 28: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/28.jpg)
Update the following:-
![Page 29: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/29.jpg)
Click
![Page 30: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/30.jpg)
Click
Update the following:-
![Page 31: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/31.jpg)
Click
Click
![Page 32: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/32.jpg)
Click
![Page 33: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/33.jpg)
Click
![Page 34: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/34.jpg)
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
![Page 35: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/35.jpg)
Click on Insert field(s) in field group
![Page 36: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/36.jpg)
Click
Hold the Ctrl key on the keyboard and select other fields also
By clicking
![Page 37: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/37.jpg)
Click
![Page 38: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/38.jpg)
Click
Click to generate the infoset
The infoset is now ready to use in the query.
Click
![Page 39: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/39.jpg)
4. Assign Infoset to User Group
Update the following:-
Click
![Page 40: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/40.jpg)
Select
Click
Click
![Page 41: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/41.jpg)
5. Create Query
Here we maintain the source fields which are to be updated with the data.
Click to select user group
![Page 42: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/42.jpg)
Select
Click
![Page 43: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/43.jpg)
Update the following:-
Click
![Page 44: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/44.jpg)
Click
Click
![Page 45: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/45.jpg)
Update the following:-
![Page 46: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/46.jpg)
Click
![Page 47: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/47.jpg)
Select
Click
![Page 48: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/48.jpg)
Update the following:-
![Page 49: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/49.jpg)
Click
![Page 50: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/50.jpg)
![Page 51: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/51.jpg)
Click
![Page 52: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/52.jpg)
Update the following:-
![Page 53: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/53.jpg)
Click
Click
![Page 54: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/54.jpg)
Click
![Page 55: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/55.jpg)
Double click
Click
![Page 56: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/56.jpg)
Double click
Similarly double click other fields to select
![Page 57: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/57.jpg)
Click
![Page 58: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/58.jpg)
Update the following:-
Click
Click
![Page 59: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/59.jpg)
Update the following:-
![Page 60: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/60.jpg)
In the above you screen shot you see that the Customer text is being showing asCustomer number. We need to change this.
Click twice
![Page 61: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/61.jpg)
Click
Click the field will open upChange it to Customer Name
![Page 62: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/62.jpg)
Click on
Click
![Page 63: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/63.jpg)
Click
Click
Click on
Click until you reach
![Page 64: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/64.jpg)
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.
![Page 65: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/65.jpg)
Let us proceed with creating a new query
1. Creating an Infoset
Update the following:-
![Page 66: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/66.jpg)
Click
![Page 67: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/67.jpg)
Update the following:-
Click
![Page 68: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/68.jpg)
Click
Update the following:-
Click
![Page 69: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/69.jpg)
Click
Click
![Page 70: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/70.jpg)
Click
Click
Select
![Page 71: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/71.jpg)
Click on Settingsà Settings
Click
![Page 72: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/72.jpg)
Select
Now click
![Page 73: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/73.jpg)
Click
![Page 74: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/74.jpg)
Position the cursor on
Click Undo relationship
![Page 75: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/75.jpg)
Click
Click
![Page 76: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/76.jpg)
Now Update the following:-
![Page 77: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/77.jpg)
Click
![Page 78: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/78.jpg)
Click
![Page 79: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/79.jpg)
Click
![Page 80: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/80.jpg)
Click
![Page 81: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/81.jpg)
Click
Click
![Page 82: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/82.jpg)
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
![Page 83: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/83.jpg)
Click until you will see
Select the following fields
![Page 84: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/84.jpg)
Select
Click
![Page 85: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/85.jpg)
Click
Click on
Click
Click
Click
![Page 86: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/86.jpg)
2. Assign Infoset to User group
Click
![Page 87: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/87.jpg)
Select
Click on
Click twice
![Page 88: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/88.jpg)
3. Create a Query
Click Other user group
Click
Click
![Page 89: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/89.jpg)
Click
![Page 90: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/90.jpg)
Uncheck
Update the following:-
Click
![Page 91: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/91.jpg)
Click
![Page 92: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/92.jpg)
Update the following:-
![Page 93: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/93.jpg)
Click
![Page 94: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/94.jpg)
Select
Click
![Page 95: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/95.jpg)
Select
![Page 96: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/96.jpg)
Click
![Page 97: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/97.jpg)
Click
![Page 98: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/98.jpg)
![Page 99: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/99.jpg)
Click
![Page 100: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/100.jpg)
Update the following:-
![Page 101: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/101.jpg)
Click
![Page 102: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/102.jpg)
![Page 103: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/103.jpg)
Click
![Page 104: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/104.jpg)
![Page 105: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/105.jpg)
Click
![Page 106: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/106.jpg)
Click
![Page 107: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/107.jpg)
Click twice
Click on
Click thrice
To execute a query
Select
And then Click
![Page 108: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/108.jpg)
4. Transporting Queries
Click
![Page 109: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/109.jpg)
![Page 110: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/110.jpg)
Update the following:-
![Page 111: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/111.jpg)
![Page 112: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/112.jpg)
Click
Click
![Page 113: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/113.jpg)
Click
![Page 114: Abap Query](https://reader034.vdocument.in/reader034/viewer/2022050807/54380377afaf9fb92e8b462e/html5/thumbnails/114.jpg)
Click