Abap Query

16
« Test standard LIS analyses with different source versions Unblock SD Documents » SQVI – Create quick report Published on January 23, 2009 in Basis . 22 Comments Tags: Basis , reporting . In an earlier post I promised to give a quickguide to creating a query in SAP based in transaction SQVI. I’m going to show you how you can quickly build a custom report for reporting Sales Schedule Lines based on different filter criteria and multiple tables (VBAK, VBAP and VBEP: header, item and schedule line data resp.): 1) Go to transaction SQVI: In the section ‘Quickviews for …’ you may see some prepared reports already. Since you are new to this it is likely to be empty. Since we are going to create a new report enter a name for the report in the Quickview name field and press < Create>. SQVI - Main screen 2) In the selection window enter descriptions and choose ‘Table join’ as ‘Data source’. This means we are going to connect and use multiple tables. Press <Enter> to continue. 3) In the screen ‘Choose data source’ press the ‘Insert table’ button. In the window that pops up enter the name of the table that you need.

Transcript of Abap Query

Page 1: Abap Query

« Test standard LIS analyses with different source versionsUnblock SD Documents »

SQVI – Create quick report Published on January 23, 2009 in Basis. 22 Comments Tags: Basis, reporting.

In an earlier post I promised to give a quickguide to creating a query in SAP based in transaction SQVI. I’m going to show you how you can quickly build a custom report for reporting Sales Schedule Lines based on different filter criteria and multiple tables (VBAK, VBAP and VBEP: header, item and schedule line data resp.):

1) Go to transaction SQVI: In the section ‘Quickviews for …’ you may see some prepared reports already. Since you are new to this it is likely to be empty. Since we are going to create a new report enter a name for the report in the Quickview name field and press < Create>.

SQVI - Main screen

2) In the selection window enter descriptions and choose ‘Table join’ as ‘Data source’. This means we are going to connect and use multiple tables. Press <Enter> to continue.

3) In the screen ‘Choose data source’ press the ‘Insert table’ button. In the window that pops up enter the name of the table that you need.

SQVI - Add table

4) Repeat the previous step for all required tables. Your screen will now look like below:

Page 2: Abap Query

SQVI - Tables

5) Press ‘F3′ to go to the configuration screen. In the left side of the screen you can select per table which fields are for selection and/or list purpose. E.g. if you only select a field as ‘List field’ it will show up in the report results, but will not appear in the selection screen of the report as a filter criterium. For the header I choose: document number, doc date, sales organization, distribution channel and sold-to party (all list and selection). On item level I select: Material Number and Reason for rejection (to be able to exclude rejected lines). Both List and Selection. For Schedule I pick: Item, Schedule Line, Schedule line category, Schedule line date and Confirmed qty. Only Schedule line category and date both List and Selection. The others only List. Now your screen will look like below.

SQVI - Fields selected

6) Now it’s time to test drive your report! Press <Execute>. It takes a short time for SAP to build te report. You are taken to the selection screen of the report. Now it is important that you have an idea of what data you are going to find. Enter filter criteria based on this idea. I mention this because you need to validate the data you will be presented in the report. Do not just accept the quantities. Analyze the results and if the numbers are off find out why and adjust your report’s  filter criteria and/or add extra filters to remove redundant data.

SQVI - Report

Page 3: Abap Query

7) If you are satisfied with the quality of the report save it for future use. It is possible to link it to a transaction code and make it accesible for users through authorization. I will post a guide on this in the future.

Kowboyz BV / CC BY-ND 3.0

Introduction to Quickviewer (SQVI)

By Shelly Malik, HFCL Connect

QucikViewer (SQVI)QuickViewer (SQVI) is a tool for generating reports. SAP Query offers the user a whole range of options for defining reports. SAP Query also supports different kinds of reports such as basic lists, statistics, and ranked lists. QuickViewer (SQVI), on the other hand, is a tool that allows even relatively inexperienced users to create basic lists. I have created a tutorial for SQVI. SQVI Tutorial

SQVI Tutorial

There might come a time that you want the information and it is spread in multiple tables. You can write a SQVI and get this info. In this tutorial we will write an SQVI to find out role assigned to users with full name of the users.You can get role assigned to users from AGR_USER table and users full name from USER_ADDR. We will join both these table to get the result.

1.       Execute transaction SQVI

2.       Create a SQVI  (z_user_role)

 and

3.       Put a title and comments. Make sure that you select Table join from  Data source

Page 4: Abap Query

4.       Click  to insert tables. Insert AGR_USERS and USER_ADDR tables.

 

5.       Select the correct join. Here we will join BNAME

Hit the back button

6.        Here I will select Role name and user name from AGR_USERS table and Full name from USER_ADDR, and also make user name as the selection field. So when I run the query it will ask me to list the users.

Page 5: Abap Query

7. Save the query and execute it. In the selection screen enter the user you want to get the info. You are ready with your SQVI query

8. Like the Data Browser (SE16) reviewed in the last article, Quickviewer (transaction SQVI) is very useful toll for quick and dirty reporting through Adhoc Queries. The advantage of using Quickviewer is it ability to perform table joins enables us to

display data from multiple tables.9. In the example below, we create a query to return the tcodes executable by an

indivdual user. We name the query “Z_USER_TCODE” using table join.10.

11. SQVI - Initial Screen

Page 6: Abap Query

12.  13.

14. SQVI - Query Definition15.  On clicking the check button, we get to the design window shown below. We

insert the three tables which we will be using for our report and add graphically add the join conditions as shown below.

Page 7: Abap Query

16.

17. SQVI - Join Conditions18.  Once the data sources and join conditions are set up, we need to check the fields

appearing in the selection and list output. We have the option or changing the field order of both the selection and list screens or even the sort order of the

resulting data.

Page 8: Abap Query

19.

20. SQVI - Selection & List Fields21.  We now save our query and click the execute button. In the example, we filter

the query to return the tcodes for user “test_user”.

Page 9: Abap Query

22.

23. SQVI - Query Selection Screen24.  The output returns a list of tcodes that can be executed by the user and also the

role which contains the tcode.25.

Page 10: Abap Query

26. SQVI - List Output

Dear Experts,

I am trying to create a query.

The requirement is based on the sales order number a query should be generated which contains the details such as Sales order number , Sales order item, Material number, Qty in SO, Invoiced qty, Bill No. Bill Item No. etc.

I tried linking the tables : VBAK, VBAP, LIPS, VBRP and VBRK

But query not running.

Can you please help me to get the correct tables and joining order in the query.

Tnx.

Abdul.

shrii

Posts: 314 Registered: 4/12/09

Forum Points: 66

 

Re: Creating SQVI - SD - Query   Posted: Feb 21, 2011 9:03 AM   in response to:

abdul khader

  Reply

Tell your abaper to create Zreport rather creating Query..

sureshsd

Posts: 207 Registered: 12/23/10

Forum Points: 302

 

Re: Creating SQVI - SD - Query   Posted: Feb 21, 2011 9:05 AM   in response to:

abdul khader

  Reply

TABLES VBAK,VBAP,VBRK,VBRP.

FIELDSVBAK-VBELNVBAP-MATWAVBAP-KWMENGVBRP-VBELNVBRP-POSNRVBRP-AUBELVBRP-FKIMG

abdul khader

Posts: 739 Registered: 7/14/07

Re: Creating SQVI - SD - Query   Posted: Feb 21, 2011 9:45 AM   in response to:

shrii

  Reply

> shrii wrote:

> Tell your abaper to create Zreport rather creating Query..

Page 11: Abap Query

Forum Points: 762

 

Tnx. for the suggestion

abdul khader

Posts: 739 Registered: 7/14/07

Forum Points: 762

 

Re: Creating SQVI - SD - Query   Posted: Feb 21, 2011 9:47 AM   in response to:

sureshsd

  Reply

Hi Suresh,

I tried it earlier but the query is not running with the combination:-

VBAK > VBAP > VBRK > VBRP

Tnx.

Abdul.

madhurao123

Posts: 1,389 Registered: 8/15/09

Forum Points: 924

 

Re: Creating SQVI - SD - Query   Posted: Feb 22, 2011 5:16 AM   in response to:

abdul khader

  Reply

Hi Abdul,

Some times if there is no link between tables you can not join.Check any standard report is there to suitable to your requirement if there is no standard Better to go for a Zreport. Give the requirement to your technical people and ask then to create a Zreport. Please tell if there is any help need in that.

Regards,Madhu.

Edited by: madhurao123 on Feb 22, 2011 5:17 AM

abdul khader

Posts: 739 Registered: 7/14/07

Forum Points: 762

 

Re: Creating SQVI - SD - Query   Posted: Feb 22, 2011 6:31 AM   in response to:

madhurao123

  Reply

tnx. madhu

All of you are telling it is not possible to create a query to get invoiced qty comparing with sales order qty based on the selection criteria as sales order no.

There is link between tables like:

VBAK > VBAP > LIPS > VBRP > VBRK

Can you please get me the tcode of std report which gives similar result (I am a PS Consultant)

Page 12: Abap Query

Tnx.

Abdul

MANOJ MAHAJAN

Posts: 1,415 Registered: 4/23/07

Forum Points: 1,592

 

Re: Creating SQVI - SD - Query   Posted: Feb 22, 2011 6:34 AM   in response to:

madhurao123

  Reply

Hello Abdul,

Please see below links for list of std reports & tables.

http://www.sap-img.com/sap-sd/important-tables-for-sap-sd.htm

http://www.sap-img.com/sap-sd/standard-sap-sd-reports.htm

You need see if you can modify the existing standard report with the help of ABAP development.

RegardsMM

madhurao123

Posts: 1,389 Registered: 8/15/09

Forum Points: 924

 

Re: Creating SQVI - SD - Query   Posted: Feb 22, 2011 6:35 AM   in response to:

abdul khader

  Reply

Hi Abdul,

I mean check when you are trying to join system will tell yo whether the join is legal or illegal. If is say illegal then you can not join.

Regards,Madhu.

Prashanth@SD

Posts: 672 Registered: 10/18/10

Forum Points: 1,546

 

Re: Creating SQVI - SD - Query   Posted: Feb 22, 2011 6:39 AM   in response to:

abdul khader

  Reply

HI

Use the tables VBAK,VBAP and VBRK,VBRP

You have to join these tabales.

Join VBAK-VBELN to VBAP-VBELN VBAP-POSNR and then VBAK-VBELN to VBRP-AUBEL and VBRP-AUPOS

regards

Page 13: Abap Query

Prashanth

abdul khader

Posts: 739 Registered: 7/14/07

Forum Points: 762

 

Re: Creating SQVI - SD - Query   Posted: Feb 23, 2011 6:44 AM   in response to:

Prashanth@SD

  Reply

Thanks prashanth..

I tried in SQVI by linking VBAK > VBAP > VBRP, and selection Sales order Number, List Display Sales order no, sales order item no. material no, cumulative sales qty, bill no, bill item no, actual invoice qty.

I got the message : "No data was selected, Message no. AQ260"

Tnx.

Abdul

Carol Anderson

Posts: 1 Registered: 2/23/11

Forum Points: 2

 

Re: Creating SQVI - SD - Query   Posted: Feb 23, 2011 4:55 PM   in response to:

abdul khader

  Reply

The Query you are trying to create will be complex. I would also recommend getting an ABAP program created.

However, if you have to use Query, you are missing link is the table for Document flow. You would have to link your VBAP table with VBFA filling in the Preceding sales document and item values and the correct document category. (Keep in mind that if you could have multiple deliveries for an order line item.)

Then you would have to link the VBFA to the LIPS table to get the delivery line, then use the VBFA table again to get the VBRP billing item.

I would assume you might have to do some minor coding in the query to make all of this work.

Hope that helps.

Carol

abdul khader

Posts: 739 Registered: 7/14/07

Forum Points: 762

 

Re: Creating SQVI - SD - Query   Posted: Feb 24, 2011 6:50 AM   in response to:

Carol Anderson

  Reply

It is possible to create the query in SQVI.

Insert Table VBAP and then Insert Table VBRP

Select the connections which automatically system proposes (there will

Page 14: Abap Query

be two connection) and delete it (one by one).

Now connect manually the tables

VBAP-VBELN = VBRP-AUBEL.

It works perfect..!!