You are on page 1of 10

Wednesday

ABAP Query - A Step-by-Step guide

Prologue
Were you looking for a detailed step-by-step document to create SAP queries and were you repeatedly turned down by irrelevant and volumnous documents? Well, I must say YOUR SEARCH ENDS HERE! as I had also gone through the same and that's what made me compose this post; A STEP-BY-STEP guide to ABAP Queries This is purposed to be the answer to all those time-consuming readings we ABAPers do to learn petty things. What you will see below is a quick reference step-by-step guide which will not only save a lot of your time, but it will also give you a good understanding of how these SAP Queries work. Enjoy it! Remember, just like all other step-by-step guides, this one too was made to be improved/modified continuously. If you like it, use it... If you don't, PLEASE HELP ME IMPROVE IT BY CRITICIZING FAULTS & SUGGESTING CHANGES.

Now let's get Started! Case:


To keep it simple, I chose a very simple case where I join the tables MARA and MAKT with basic Material details and descriptions as the output. T.Code SQ03 Create user group, enter description & save

Enter User Group name & Click on CREATE Enter description in the next screen (below)

Save

After saving click on the button Assign users and Infosets

Multiple users can be assigned to the group After assigning, save & go back

To know the Users settings click on the Description button in the main screen you can get the details as below

Now go to T.Code SQ02 Create Infoset, join & relate tables

Enter Infoset name & Click on CREATE Enter description in the next screen (below) Enter main table name in the fiels circled in red below

The Infoset's initial screen will appear with the table specified earlier (as shown below)

Now click on the (encircled in red) to insert the next Table for joining (MAKT in this case)

As soon as you mention the table name and hit Enter, the Infoset screen will display the seciond table showing the primary key link to the base table as shown below (MATNR in this case)

Now check the Infoset for inconsistencies and on finding none, you can bo back by clicking the BACK button

After clicking the BACK button the below screen appears in that choose the option Create Empty Field Groups

Once the above selection is been selected the below screen appears with collapsible menus for each table to seledct fields for selection and display Drill down the tables and simply drag and drop the fields to the right hand side to their respective tables

The selected fields are displayed in the screen below Now Check the Infoset for inconsistencies; on finding none, SAVE and GENERATE

Then click the button "ROLE/USER GROUP ASSIGNMENT" in the main screen to assign the Role. The Below screen appears in that Activate the Assigned table against the User Group name ZKAR_UG

Now save & go back

Now go to T.Code SQ01

Click on the button "INFOSET QUERY" to see the screeb below Select the ifnoset ("ZKAR_INFOSET" in thos case)

After selecting the InfoSet below screen appears Here you can select the fields for output and selection separately

Ensure the Output & the Selection Fields are in VALUE & Not in TEXT. If it is a TEXT then in the screen in the menu bar you have EDIT option in that select SETTINGS the below screen comes in that ensure the Selection & the output is in VALUES

In the Output tab ensure the Type of Output list as BASIC LIST & the Type of Output as SAP LIST VIEWER

In the Default: Val/Text Tab ensure for the Output & Selection the VALUE radio button is selected

Now click enter

In that select which are the fields to be the selection fields & which are the fields to be the listed fields, that is the output fields. After doing the above process save the settings by clicking the save button & go back When you click the save button the below screen appears in that Query Name will be generated automatically by the System Title can be defined by us

Thats it!!! your SAP Query is ready. Click on Execute to run the Query

Assigning a t-code to your query is simple. There are 2 ways to it... 1. Execute the query; go to "Status" on menu bar; take the program name; go to SE93; create & assign your own "Z" transaction to the query 2. Go to query - more functions - reportname; take the program name; go to SE93; create & assign your own "Z" transaction to the query