Top Banner

of 25

How to Write a Query

Apr 08, 2018

Download

Documents

Venkata Pulusu
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 8/7/2019 How to Write a Query

    1/25

    Copyright2008You can not redistribute, sell or change content of this e-book without written permission

    from the authorImportant:The author and publisher have made every effort to ensure the accuracy of the information

    herein. However, the information contained in this book is distributed without warranty,

    either express or implied. Neither the authors nor its distributors will be held liable for any

    damages to be caused either directly or indirectly by the instructions contained in this book,

    or by the software or hardware products described herein.

  • 8/7/2019 How to Write a Query

    2/25

    How to create a SAP Query using InfoSet

    There are different types of queries available in SAP. This is a very interesting, simple

    and very effective tool. Today I am going to show you how you can create a query usingInfoSets.

    There are three main steps in writing a query. They are;

    1.Creation of User Groups (Defines who is going to create, modify and use thequery)

    2.Creation of InfoSet (Defines the set of data used in the query)3.Creation of the Query (Generating reports using the data)

    Generally there is no need for you to carryout the first two steps for every query youwrite. Once created you can reuse them in queries. But for this demonstration I am taking

    you through these steps as well.

    For this demonstration I will create a user group called DEMO. I want to write a query

    to pull information regarding purchase orders. I need purchase order header data,

    purchase order line item data and account assignment data to generate my report.

    Step 1: Creation of User Groups (Transaction SQ03)

    1.Go to the screen SQ012.Enter the Group Name you want to create and press Create

    3.Then you can enter a description to the user group and press save

    http://www.sapafs.net

    http://www.sapafs.net/http://www.sapafs.net/
  • 8/7/2019 How to Write a Query

    3/25

    4.Now you have created the User Group called DEMO

    http://www.sapafs.net

    http://www.sapafs.net/http://www.sapafs.net/
  • 8/7/2019 How to Write a Query

    4/25

    Step 2: Creation of InfoSet (Transaction SQ02)

    1.Go to the transaction SQ022.Enter a Name to your InfoSet and Press the Create Button

    3.You will get the PopUp window.a.Enter the Descriptive name to your InfoSetb.Select the data source you are going to use. I am using table join to get the

    maximum flexibility

    c.Enter the First table you are going to get the data from( I am entering thetable EKKO to get the header data of purchasing dosuments)

    4.Press Continue

    http://www.sapafs.net

    http://www.sapafs.net/http://www.sapafs.net/
  • 8/7/2019 How to Write a Query

    5/25

    5.Now you will see the table you inserted. To insert other tables click on the InsertTable Button

    6.In the PopUp window type the table you want to insert next and press continue. Iam inserting the PO Line Item level data table EKPO here

    7.Enter the Continue button. You will see the tables with automatic joining

    http://www.sapafs.net

    http://www.sapafs.net/http://www.sapafs.net/
  • 8/7/2019 How to Write a Query

    6/25

    8.Then hit the Insert Table button Again and enter the nest table. I am entering the

    table EKKN to get the account assignment data

    http://www.sapafs.net

    http://www.sapafs.net/http://www.sapafs.net/
  • 8/7/2019 How to Write a Query

    7/25

    http://www.sapafs.net

    http://www.sapafs.net/http://www.sapafs.net/
  • 8/7/2019 How to Write a Query

    8/25

    9.Enter the Continue button. You will see all the tables we require with automaticjoins

    10.

    I am expanding the size of the tables in the display by dragging them by handles

    and adjusting sizes

    http://www.sapafs.net

    http://www.sapafs.net/http://www.sapafs.net/
  • 8/7/2019 How to Write a Query

    9/25

    11.In the proposed links between the tables EKKO and EKPO there is a link which Ido not require. I am removing the link between the last item number with the PO

    LI ( EKKO LPONR -> EKPO EBELP)

    12.Right Click on the link and Select Remove Join Condition

    http://www.sapafs.net

    http://www.sapafs.net/http://www.sapafs.net/
  • 8/7/2019 How to Write a Query

    10/25

    13.Now press Check Button. If there are any errors in linking that will behighlighted.

    http://www.sapafs.net

    http://www.sapafs.net/http://www.sapafs.net/
  • 8/7/2019 How to Write a Query

    11/25

    14.You will see the result of the check in the bottom of your screen.

    http://www.sapafs.net

    http://www.sapafs.net/http://www.sapafs.net/
  • 8/7/2019 How to Write a Query

    12/25

    15.Now hit the back button16.You can limit the number of fields the InfoSet contain. But here I am going to

    include all the fields in the InfoSet

    17.Select the Include all table fields button and press continue

    18.Now you can see all the field groups which are created. When you click on them

    you will see all the fields each of them contain

    http://www.sapafs.net

    http://www.sapafs.net/http://www.sapafs.net/
  • 8/7/2019 How to Write a Query

    13/25

    19.Now we can generate the InfoSet by hitting the Generate Button

    http://www.sapafs.net

    http://www.sapafs.net/http://www.sapafs.net/
  • 8/7/2019 How to Write a Query

    14/25

    20.After this hit the Back Button21.Now we have generated our InfoSet to be used in the query. Now we have to tell

    the system who can Change/Use this InfoSet

    22.To do this Select the InfoSet you are going to assign and then Click the UserGroup Assignment Button23.Select the User Group and press save. In this case I am going to assign my InfoSetto the user group DEMO we created in the beginning

    http://www.sapafs.net

    http://www.sapafs.net/http://www.sapafs.net/
  • 8/7/2019 How to Write a Query

    15/25

    24.Now the step 2 is completed. Now we can write the query. Go back to the SAPSession Manager screen by hitting back button

    http://www.sapafs.net

    http://www.sapafs.net/http://www.sapafs.net/
  • 8/7/2019 How to Write a Query

    16/25

  • 8/7/2019 How to Write a Query

    17/25

    4.Now Give your query a name and press the button Create

    5.System will prompt you with a selection screen containing InfoSets assigned toyour user group. Select the one you are going to use and then press the buttonChoose. In this case I have only one InfoSet created earlier. I am selecting that

    for my query.

    http://www.sapafs.net

    http://www.sapafs.net/http://www.sapafs.net/
  • 8/7/2019 How to Write a Query

    18/25

    6.Now you can give your query a neme and add some notes for references and hitthe Save button

    http://www.sapafs.net

    http://www.sapafs.net/http://www.sapafs.net/
  • 8/7/2019 How to Write a Query

    19/25

    7.Hit the Back Button to get to the Query Main screen8.Now highlight the query you created and select the InfoSet query Button to cerate

    the query

    9.Now you can select the fields which you want to use in Selection Criteria andfields which you need to Display In the Report By checking the Check Boxes near

    each field. You will see all the selection information to your right and to thebottom of your screen

    10.I am selecting the Purchase order Number and the Purch group and release statusfrom the header data. From the item level I am mainly selecting the LI number

    and the material and its description, PO quantity and the deletion indicator with

    the AFS indicator. From the Account assignment details I am selecting the SalesOrder Number and the Sales Order line Item Number

    http://www.sapafs.net

    http://www.sapafs.net/http://www.sapafs.net/
  • 8/7/2019 How to Write a Query

    20/25

    http://www.sapafs.net

    http://www.sapafs.net/http://www.sapafs.net/
  • 8/7/2019 How to Write a Query

    21/25

    http://www.sapafs.net

    http://www.sapafs.net/http://www.sapafs.net/
  • 8/7/2019 How to Write a Query

    22/25

    11.After selecting all your filtering and display fields press save to save your workand hit the back button to get back to the main screen

    http://www.sapafs.net

    http://www.sapafs.net/http://www.sapafs.net/
  • 8/7/2019 How to Write a Query

    23/25

    12.Now you can select and press the execute button and to run the query

    http://www.sapafs.net

    http://www.sapafs.net/http://www.sapafs.net/
  • 8/7/2019 How to Write a Query

    24/25

    13.Enter your filtering criteria and hit the execute button to run the report

    14.Hooray ! Here It is. Our query is working fine

    http://www.sapafs.net

    http://www.sapafs.net/http://www.sapafs.net/
  • 8/7/2019 How to Write a Query

    25/25

    15.Do changes to your query until you get your desired result and information outfrom it