22
SAP R/3 Technique User manual : SAP Query Date: 12 September, 2011

SAP query

  • Upload
    rhico

  • View
    157

  • Download
    6

Embed Size (px)

Citation preview

Page 1: SAP query

SAP R/3 Technique

User manual : SAP Query

Date: 12 September, 2011

Page 2: SAP query

13 January 2010

Page 2

1. TABLE OF CONTENTS

1. TABLE OF CONTENTS 2

2. CHANGE HISTORY 3

3. GENERAL 4

3.1. Analysis 4

4. HOW-TO PROCEED 5

4.1. Create user group 5 4.1.1. Create user Group 5

4.2. Create infoset 6

4.3. Choose the Display-fields 8

4.4. Add additional fields 8 4.4.1. Add the fields 9 4.4.2. Add the code 10

4.5. Link infoset and user to user group 11

4.6. create the query 12 4.6.1. General 12 4.6.2. Output fields 13 4.6.3. Selection fields 16 4.6.4. Basic list layout 16

4.7. Link a transaction code to the query 17 4.7.1. Search program name 18 4.7.2. Link transaction code to query 18

4.8. Link hotspot 21

Page 3: SAP query

13 January 2010

Page 3

2. CHANGE HISTORY

Date Details Author Version

Page 4: SAP query

13 January 2010

Page 4

3. GENERAL

3.1. ANALYSIS

SAP (or ABAP) query can be used to generate reports on a rather simple way. This document

is a very short manual on how-to create such a report. This document is not a complete

manual, but rather a document that can be used as a guide.

Page 5: SAP query

13 January 2010

Page 5

4. HOW-TO PROCEED

4.1. CREATE USER GROUP

A User group is needed to link certain users with the queries (which will be created later on)

and generated reports.

Transaction code : SQ03

Path : Tools – ABAP Workbench- Utilities – SAP query - SQ03

4.1.1. Create user Group

Fill in a name and click on Create

Fill in a description.

Choose package and transport request.

We will link the users and queries in a later stage

Page 6: SAP query

13 January 2010

Page 6

4.2. CREATE INFOSET

Transaction code : SQ02

Path : Tools – ABAP Workbench- Utilities – SAP query - SQ02

There are two approaches to create an infoset :

a. Infoset based on a logical database

b. Infoset based on directly linked tables

a. Logical database

Logical databases are special ABAP programs that retrieve data and make it available to

application programs. A logical database provides a particular view of database tables in

the R/3 System.

b. Linked tables.

Use a table as head-table and link other tables afterwards.

First thing we have to do, is create the infoset. Fill in a name and click on create.

Fill in the data.

For this example, we’ll create a simple sales order list, so we take VBAK as table. This is the

table with header data for sales orders.

We take the option Table join using basis table because we will add other tables .

Page 7: SAP query

13 January 2010

Page 7

Add the other tables by clicking on edit – insert table

For the example, we add following tables :

- VBAP : table with sales order items.

- KNA1 : main data for customers

- VBPA : table with link between the sales order item and partner function

Page 8: SAP query

13 January 2010

Page 8

Click on BACK (green arrow).

Mark the option Create empty field groups.

4.3. CHOOSE THE DISPLAY-FIELDS

On the left side, you’ll see the tables you have selected with all their fields.

On the right side, you’ll see the already selected fields.

You can add a field by dragging it from the left to the right.

If necessary, change the column header from the field.

When finished, click on save.

4.4. ADD ADDITIONAL FIELDS

Page 9: SAP query

13 January 2010

Page 9

4.4.1. Add the fields

If needed, you can add additional fields to the report. (which can be filled up using ABAP

code).

We use the example which links the partner function code to the long text (e.g. AG -> bill-to

party)

Click on extra.

Select the tab extras and create a new field

Tpart-vtext is the field in the database which contains the long text for the partner function

name

Page 10: SAP query

13 January 2010

Page 10

4.4.2. Add the code

Select the additional field by clicking on it and click on the add code-button.

Select DATA . We define our variables here.

Go to record processing and add the code to read the added field.

Save your infoset.

DO NOT FORGET TO GENERATE THE INFOSET !!

Infoset – generate

Page 11: SAP query

13 January 2010

Page 11

4.5. LINK INFOSET AND USER TO USER GROUP

Transaction code : SQ03

Fill in your name from the user group, and click on assign users and infosets.

Fill in the persons which are allowed to execute the query and infosets.

After that, click on assign infosets

Search your infoset and mark it. Click on save.

Page 12: SAP query

13 January 2010

Page 12

4.6. CREATE THE QUERY

Transaction code : SQ01

4.6.1. General

Fill in the name and choose the infoset you want to use.

Click on create.

Fill in the needed info.

Page 13: SAP query

13 January 2010

Page 13

Click on next.

4.6.2. Output fields

Select the field groups where there are fields which you want to show in the output

Page 14: SAP query

13 January 2010

Page 14

Click on next.

Select the fields which you want to show

Page 15: SAP query

13 January 2010

Page 15

Click on next.

Page 16: SAP query

13 January 2010

Page 16

4.6.3. Selection fields

Mark the fields which you want to use as selection parameter.

Click on basic list.

4.6.4. Basic list layout

Mark the items which need to be displayed in the sequence that you want them to be showed.

(mark tem under the field list fields)

Page 17: SAP query

13 January 2010

Page 17

On the right, you’ll see an example of how the output will be.

Save and exit.

4.7. LINK A TRANSACTION CODE TO THE QUERY

Page 18: SAP query

13 January 2010

Page 18

4.7.1. Search program name

We have to search the program name from the query. Do this by filling in the query name in

transaction SQ01.

(do not press Enter)

Click on Query – more functions – display report name. Copy it.

4.7.2. Link transaction code to query

Go to transaction code SE93.

Fill in the desired transaction code and click on create.

Page 19: SAP query

13 January 2010

Page 19

Fill in a short description and choose for program and selection screen

Fill in the program name.

Mark the three options under SAP GUI.

Page 20: SAP query

13 January 2010

Page 20

Page 21: SAP query

13 January 2010

Page 21

4.8. LINK HOTSPOT

You can link a transaction to the report which will open when you double-click on that line.

Click on Go To -> Report Assignment

Add a line by clicking on the plus-sign

Choose Other report type

Click on Transaction

Page 22: SAP query

13 January 2010

Page 22

Fill in the transaction you want and click on Ok