Sie sind auf Seite 1von 34

A Primer for Queries: ABAP, SAP,

QuickViewer, and InfoSet Queries






SDN Community Contribution
(This is not an official SAP document.)


Disclaimer & Liability Notice
This document may discuss sample coding or other information that does not include SAP official interfaces
and therefore is not supported by SAP. Changes made based on this information are not supported and can
be overwritten during an upgrade.
SAP will not be held liable for any damages caused by using or misusing the information, code or methods
suggested in this document, and anyone using these methods does so at his/her own risk.
SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of
this technical article or code sample, including any liability resulting from incompatibility between the content
within this document and the materials and services offered by SAP. You agree that you will not hold, or seek
to hold, SAP responsible or liable with respect to the content of this document.

2005 SAP AG The SAP Developer Network: http://sdn.sap.com 1
A Primer for Queries: ABAP, SAP,
QuickViewer, and InfoSet Queries

Applies To:
SAP R/3 System
Release 4.6C (SAP Web AS 6.10)
Summary
SAP Queries are also known as "Report Generating Tools." This primer describes various tool options for
using Query tools in the ABAP context: the old ABAP/4 Query tool is described in detail as it was the
prototype for the newer query tools such as the SAP Query, the QuickViewer, and the InfoSet Query. The
tools will be described from two perspectives: the view of the end user who creates queries and generates
lists and has little programming knowledge, and the ABAP developer who must handle certain administrative
tasks of the Query environment.
By: Marilyn Pratt, with ABAP/4 from Garry Carson
Company: SAP
Date: 01 Nov 2005
Table of Contents
Applies To:........................................................................................................................................2
Summary..........................................................................................................................................2
Table of Contents.............................................................................................................................2
What is a Query?..............................................................................................................................3
What is an ABAP/4 Query?..............................................................................................................3
Functional Areas in ABAP/4 Queries ...............................................................................................4
Additional Tables in ABAP/4 Functional Areas ................................................................................8
Steps to Add Additional Tables ....................................................................................................9
Additional Fields in ABAP/4 Functional Areas ...............................................................................10
Selection Criteria and Parameters in ABAP/4 Functional Areas....................................................12
User Groups in ABAP/4 Queries....................................................................................................13
ABAP/4 Queries .............................................................................................................................15
Basic Lists in an ABAP/4 Query.....................................................................................................21
Executing the ABAP/4 Query.........................................................................................................26
Ranked Lists in ABAP/4 Queries....................................................................................................27
Using Report/Report Interface in ABAP/4 Queries ........................................................................29
2005 SAP AG The SAP Developer Network: http://sdn.sap.com 1
A Primer for Queries: ABAP, SAP,
QuickViewer, and InfoSet Queries

What is an SAP Query? .................................................................................................................32
What is a QuickViewer Query? ......................................................................................................33
What is an InfoSet Query? .............................................................................................................33
Query Tools Summary Matrix.........................................................................................................34
Author Bio.......................................................................................................................................34
What is a Query?
Queries in the SAP context are easy to use reporting tools that allow a user to interrogate data from one or
more database tables and report on the results as output. Query tools allow one to extract data from
applications or database tables in the R/3 system and they enable the results of the extraction to be displayed
in list format. Query tools generate ABAP programs which can run as list reports and output can be
displayed in various modalities, depending on the query tool and the output selection of the end user. These
outputs can include lists on screens in table format, ALV grids, downloadable spreadsheets, and
downloadable flat files. The internal report generator creates an ABAP program corresponding to the
definition of the list.
Query tools all share these following elements:
Queries are feed from a data source: depending on the tool, these feeds could be tables, joins,
logical database contents (pre-defined joins for application areas), ABAP dictionary views,
infosets and functional areas (also pre-defined data sources, administered and secured expressly
for the purpose of generating query lists).
Queries provide list definition including field sequence, sort order, selection criteria, ranked lists,
summarized lists
Queries provide output definition which, as mentioned above, can include simple lists on
screens in table format, ALV grids (end user configurable outputs), downloadable spreadsheets,
and downloadable flat files.
What is an ABAP/4 Query?
The ABAP/4 Query was the precursor of the SAP Query (prior to version 4.6). Since it was used in earlier
R/3 releases it originally was defined using a more alphanumeric environment than the SAP Query or the
InfoSet Query. I have replicated that in this primer for historical reasons. The three main components of
ABAP/4 Query are functional areas, user groups and queries. Functional areas determine the fields from
specific tables which are available to be queried on. A user group contains a list of users, for example, the
GL department or Sales department. Functional areas are assigned to a user group and the users within the
user group only have access to functional areas that have been assigned to their user group. Queries are
also created within a user group.
The key to designing an ABAP/4 Query is knowledge of the fields that are needed and getting the functional
areas created correctly. The person responsible for creating functional areas needs to be familiar with the
table structures and fields. The ABAP/4 Querys three components: a Functional Area, a User Group, and
a Query, are each accessed by a separate transaction code, SQ02, SQ01, SQ03.
The Data Source of the ABAP/4 Query was called a Functional Area. The functional area was a way to offer
a pre-defined set of data to the user, limiting the scope to a particular functional area of R/3, thus limiting the
2005 SAP AG The SAP Developer Network: http://sdn.sap.com 1
A Primer for Queries: ABAP, SAP,
QuickViewer, and InfoSet Queries

kind and amount of the data to be queried. Since the system contains hundreds of thousands of data fields in
tables, views, and logical databases, the thinking went that not only could you restrict the user as to what data
and in which tables they could query against, but also who would be doing the querying. Therefore, an
additional administrative concept was created called the User Group which essentially defined those users
whose role would allow them to access the particular functional areas assigned to that user group.
From an end user perspective, a Query is the way of creating different lists, or outputs using different layouts
for each list. Each layout set is called a query and the query is specific to a user group and functional area.
Each query has a one to one correspondence with a functional area.
Generally speaking, it is a developer or administrator who would design the Functional Areas and User
Groups, while the user would design the layout of the queries and of course, execute them.
In an ABAP/4 Query, the data source would need to be established in advance. Functional Areas could
include multiple tables, joins, views, or logical database utility programs, reading data from multiple data
sources. In the context of a Functional Area, a developer or administrator could also define additional fields.
ABAP/4 Query supports ranked lists, and summaries, as well as basic lists.
As a general rule, non-technical users probably would find it difficult to work with the creation of additional
fields, table joins and logical databases, as well as coding additions. For this reason, functional areas and
logical databases are generally not the realm of end users.
It is important to note that queries can create performance problems, so although the query tool is easy to
work with, it is probably wise to control the usage of the tool in order to maintain optimal system performance.
These are the main steps that need to be completed to create a query.
1) Create a Functional Area
2) Generate the Functional Area - Dont forget this step!
3) Create a User Group
4) Attach the Functional Area to the User Group (This is done in the user group or the functional area)
5) Create the Query
Functional Areas in ABAP/4 Queries
1) Under System Services ABAP/4 Query Environment Functional Areas, enter the
functional area name and select a processing option. A functional area name is up to four characters
and may begin with a numeric or alpha character.
2005 SAP AG The SAP Developer Network: http://sdn.sap.com 1
A Primer for Queries: ABAP, SAP,
QuickViewer, and InfoSet Queries


2) Give the functional area a description.
3) The authorization code is an optional field to work with authorizations.
4) Fixed point arithmetic should be on! This field ensures that your decimal places are held in the correct
places for calculations.
5) Only one of the two following areas should be filled in:
a. Functional area with logical database - If you are using a logical database, enter the two
digit database code and the application code. For a listing of logical databases, use the
search available on the database field. This will list all of the delivered logical databases or
you may create your own logical database. Logical databases are groups of tables with the
relationships determined within the logical database code. All tables related to general ledger
accounts is an example.
b. Functional area without logical database - In this section you have a choice to enter a
table and additional table joins if necessary. Table joins are new in 3.0 and are considered
more efficient in most cases than logical databases. You must include the main table for the
functional area in the table field. If you are adding additional tables via the table join
functionality, select the table join radio button and hit the 'Define J oin' button. Table joins are
described in detail below.
2005 SAP AG The SAP Developer Network: http://sdn.sap.com 1
A Primer for Queries: ABAP, SAP,
QuickViewer, and InfoSet Queries

6) Enter the tables to be joined to the main table and hit the enter key. J oin the tables by selecting 2
tables and hitting the 'Define condition' button. The conditions will appear on the right hand side of the
screen. Each condition must be further defined by placing your cursor on the join condition and
selecting the down arrow that appears to the right of the line. When hitting the down arrow, a
message will appear to ask whether you would like to see proposals. Hit "yes" to this. The system will
propose what fields to join together in the two tables.

7) Enter the tables to be joined to the main table and hit the enter key. J oin the tables by selecting 2
tables and hitting the "Define condition" button. The conditions will appear on the right hand side of
the screen. Each condition must be further defined by placing your cursor on the join condition and
selecting the down arrow that appears to the right of the line. When hitting the down arrow, a
message will appear to ask whether you would like to see proposals. Hit "yes" to this. The system will
propose what fields to join together in the two tables.
2005 SAP AG The SAP Developer Network: http://sdn.sap.com 1
A Primer for Queries: ABAP, SAP,
QuickViewer, and InfoSet Queries


8) To deselect one of the proposed join conditions, follow the menu path Edit J oin Deselect
relation. To add field join conditions, enter the next set of corresponding numbers to the field from
each table that should be matched.
9) Once the conditions have all been defined, hit the green arrow key back to the join screen.
10) Complete this for each set of tables to be joined.
11) When finished, hit the save button.
Note: Additional tables may be included in a functional area from the functional groups section. This is in
addition to logic database tables or table joins, whichever is being used in your functional area. This is
described later in this document.
12) Hit the "Functional Groups" button to access the next screen.


2005 SAP AG The SAP Developer Network: http://sdn.sap.com 1
A Primer for Queries: ABAP, SAP,
QuickViewer, and InfoSet Queries


Fields are not available for queries unless they are assigned to a functional group within your functional area.
Functional Groups are logical groupings of fields for reporting.
Create your functional groups by inputting a two digit code and a description in the functional groups section
of the screen.
The possible tables to select fields from are listed in the top right hand corner. These tables are either from
the logical database or the table/table joins selected for the functional area. To select fields from a table,
double click on the table and the fields for that table will appear in the bottom portion of the screen. To page
down through the tables, your cursor must be in the table portion of the screen.
In the space next to the fields in the bottom of the screen, put the two digit functional group code. This will
assign the field to the group. To page down through the fields, the cursor must be in the Fields portion of the
screen. If you would like the entire screen to list the fields, tables, or functional groups instead of the default
split screen, use Settings ->Full Screen. To return to the split screen, use Settings ->Split Screen.
Additional Tables in ABAP/4 Functional Areas
Additional tables are added to a functional area if a field needed for queries is not available in the selected
logical database or the specified single table/table joins section.
Each additional table does create an additional select statement within the program for your query, so try not
to add too many additional tables.
The table the system will attempt to attach to the additional table is the highlighted table with the fields listed
at the bottom of the functional group screen.

2005 SAP AG The SAP Developer Network: http://sdn.sap.com 1
A Primer for Queries: ABAP, SAP,
QuickViewer, and InfoSet Queries

To attach a table, all of its key fields must exist on the table to which you are attaching. To determine what
the key fields are, go to the data dictionary. The key fields are the fields with an "X" in the key column. The
menu path to get to the data dictionary is:
Tools ABAP/4 Workbench Data Dictionary
In the example below, we are adding the account description table to the functional area. This table is not
included in the logical database for general ledger accounts.
Steps to Add Additional Tables
Hit the "SAP Table" button on the functional groups screen. Enter the table name and hit enter. The system
will automatically fill in the matching fields for you. If the field names do not match, the system will leave that
field blank and you will have to enter the field name or value in single quotes needed to make the connection
for the two tables.

A select single * statement goes to the table being attached when necessary and selects the one record
which matches the key fields. In the example, the system will go to table SKAT (or whatever table you are
attaching) and search until it finds the correct chart of accounts, account number, and language. The fields in
SKAT are then pulled into the query for that combination.
The fields from the attached table can be found at the bottom of the field listing for the table to which it was
attached. These fields must also be assigned to a functional group.
2005 SAP AG The SAP Developer Network: http://sdn.sap.com 1
A Primer for Queries: ABAP, SAP,
QuickViewer, and InfoSet Queries


ABAP Query does not access attached tables during the execution of the query unless fields from the table
are used within the query.
Additional Fields in ABAP/4 Functional Areas
Additional fields may be added to a functional area for calculations or derived fields. For example, amounts
are stored as positives and the posting key determines the sign of the amount. When reporting these amounts
they will show up positive unless you add additional fields for the sign to show with the amount.
To add additional fields, hit the "Additional Field" button on the Functional Groups screen. Additional fields
also attach to the selected table in the functional area, so be sure you are on the correct table.
Enter a name for the additional field (all one word or a string) and hit the "Enter" key.
2005 SAP AG The SAP Developer Network: http://sdn.sap.com 1
A Primer for Queries: ABAP, SAP,
QuickViewer, and InfoSet Queries


Description of Screen
The "Sequence of code" section specifies the order in which the tables are attached and the additional fields
are added. If you attach a table and you need to add a field using fields from the attached table, the table
would need to be sequence 1 and the additional field needs to be sequence 2. If additional fields and tables
are not dependent on each other, they can both be sequence 1.
The next two fields are description fields. One is for the Query selection and the other is for the column
heading in the query.
"Format" can be entered in two ways. If the field format is known, it may be entered in directly. The type is
character, numeric, packed, etc. Length is the total length of the field. Output length is the display length
within the query (including decimals and commas). Decimals are the decimal places. The second way to enter
the characteristics is to enter a field that is formatted like the field you are creating. The example above is
BSEG-DMBTR, which is the local currency amount field on the FI line item table.
The last section is for ABAP code. The five lines on the screen are the first five lines of code for the
additional field. To enter additional lines, hit the pencil and paper button.
Additional fields also have to be added to a functional group. The additional field, just like the additional
tables, can be found at the bottom of the field list for the table it was attached to.
2005 SAP AG The SAP Developer Network: http://sdn.sap.com 1
A Primer for Queries: ABAP, SAP,
QuickViewer, and InfoSet Queries


Selection Criteria and Parameters in ABAP/4 Functional Areas
Additional parameters and selection statements can be added to the functional area if needed. Hit the
appropriate button on the functional group screen to create them. If you are using a logical database, certain
fields are included as selection criteria when executing a query.
Suggestion: Execute a query on the functional area and determine if the selection field you want is standard
with the logical database. If not, add it to the functional area.
Using Selection Criteria and parameters in the functional area can give you the following options:
Search capability
Make a field required for entry
Set a default for the field
Make a field highlighted in the selection screen
Make a field display only in the selection screen
These options are entered in the "Additions" line of the selection criteria or parameters. The syntax is the
same as if entering selection criteria in an ABAP program. In the example below, the G/L account field is
being setup as selection criteria for the functional area.
2005 SAP AG The SAP Developer Network: http://sdn.sap.com 1
A Primer for Queries: ABAP, SAP,
QuickViewer, and InfoSet Queries


This is the last step of creating a functional area. Now the functional area must be generated! Select the
generate button.
User Groups in ABAP/4 Queries
User groups are used to control access to functional areas and queries. Functional Areas and Users are
assigned to user groups. When a user goes into ABAP/4 Query to create a query, the user group they are in
determines the functional areas they have access to for their query.
System Services ABAP/4 Query Environment User Groups

2005 SAP AG The SAP Developer Network: http://sdn.sap.com 1
A Primer for Queries: ABAP, SAP,
QuickViewer, and InfoSet Queries


This screen is for maintenance of user groups and assigning functional areas to user groups.
Note: Don't forget to assign functional areas to the user groups by hitting the "Assign Functional Area" button.
To assign users to a user group, enter in their logon ID.
2005 SAP AG The SAP Developer Network: http://sdn.sap.com 1
A Primer for Queries: ABAP, SAP,
QuickViewer, and InfoSet Queries


ABAP/4 Queries
To access queries:
System Services ABAP/4 Query
On the initial screen, enter in the query name and select a processing option. If the wrong user group comes
up, change it by Edit Other User Group or by hitting the "Other User Group" button (first button on the left).
2005 SAP AG The SAP Developer Network: http://sdn.sap.com 1
A Primer for Queries: ABAP, SAP,
QuickViewer, and InfoSet Queries


If the user group contained queries, they would be listed on the screen. A user can execute any query in his
user group if he has the authorization. Query does work with SAP authorizations; for example, if a user does
not have viewing access to cost center 1100 then he cannot access that information in a query.
The following screens step through the creation of a query.
2005 SAP AG The SAP Developer Network: http://sdn.sap.com 1
A Primer for Queries: ABAP, SAP,
QuickViewer, and InfoSet Queries


1) A list of the functional areas available for your user group will appear. Select the functional area you
would like to use for the query. Only one functional area is allowed per query.


2005 SAP AG The SAP Developer Network: http://sdn.sap.com 1
A Primer for Queries: ABAP, SAP,
QuickViewer, and InfoSet Queries

2) The report title appears on the Windows title bar when the query is executed. This title does not print
when the query is printed unless the Print list, "with standard title," button is on.
Notes can contain any documentation for the query.
The list format must match an existing print format in spool administration or the query will not print!
3) To continue on to the next screen, hit the "Next Screen" button (the first button on the left). Once a
person is familiar with the screens, under the Goto menu option you may move to specific screens
within the query.

4) Select the functional groups that contain the fields needed for the query.
5) Hit the "Next Screen" button.
2005 SAP AG The SAP Developer Network: http://sdn.sap.com 1
A Primer for Queries: ABAP, SAP,
QuickViewer, and InfoSet Queries


6) Select the fields needed for the query. They are listed by functional group.
The "+/-" sign at the bottom of the screen pages down or up through the possible fields.
7) Hit the "Next Screen" button to continue.
2005 SAP AG The SAP Developer Network: http://sdn.sap.com 1
A Primer for Queries: ABAP, SAP,
QuickViewer, and InfoSet Queries


Note: This screen is different then the previous screen! This screen only contains the fields selected for the
query on the previous screen.
Select fields on this screen that should be run time options when executing the query. This means the query
will ask you to enter a Chart of Accounts or Account numbers when executing the query. These are not
required to be entered at runtime, they are all optional. If the runtime fields are left blank at execution, all data
is pulled.
Remember: If the functional area is using a logical database, it will have certain selection fields. If you select
the fields here and they are included in the logical database selections, the fields will appear twice at
execution.
The selection text may be changed. For example if storing an old account number in the Group Account field,
the text can be changed from "Group Account" to "Old Account Number." When the query is executed, it
would ask for "Old Account Number."
The "+/-" at the bottom of the screen pages up or down through the fields.
This is the only screen that does not contain a "Next Screen" button. Hit the "Basic List," "Statistics," or
"Ranked List" button to continue. All three may be created in one query. Basic list is the most common. This is
a listing of the data selected for the query, sorted and totaled however specified. Ranked List will provide a
summarized ranking of the selected fields based on whatever criteria is selected, normally an amount field.
Statistics will provide a statistical listing based on an amount/quantity field. Basic List and Ranked List are
shown in this document.
2005 SAP AG The SAP Developer Network: http://sdn.sap.com 1
A Primer for Queries: ABAP, SAP,
QuickViewer, and InfoSet Queries

Basic Lists in an ABAP/4 Query

The line field specifies which line of the detail the field should be contained on. Based on the width specified
on the first screen in the query, the fields may not fit on one line. Therefore, multiple lines may be specified. If
a line is longer than the specified length for the query (on the header screen for the query), the lines will wrap.
The sequence is the column the field will be placed in on the designated line.
Sorting is done with the Sort field. There are subsequent screens to be filled in for each field a sort is done on.
The total button determines that a total will be calculated for the field. This button is only valid for quantity and
amount fields. If this button is turned on, a total will automatically be created for the whole query. Totals may
also be calculated for the sort fields.
The box button at the top of the screen works with the sort fields on the next screen. If you want a box drawn
around each new section for your sort fields, you must select the box button here as well as on the next
screen.
The compress data screen button at the top of the screen will compress the detail when executing the report.
For example, if a G/L account history query is written, the compress button will suppress the detail on the
initial execution of the query. You have the option to show the detail by hitting the expand button on the
executed query.
Hit the "Next Screen" button to continue.
2005 SAP AG The SAP Developer Network: http://sdn.sap.com 1
A Primer for Queries: ABAP, SAP,
QuickViewer, and InfoSet Queries


This screen is for setting up the sort fields defined on the previous screen.
The "Desc" field is for descending order. The default is ascending.
If the sort field should have text at the beginning of each new occurrence, select the Text button.
The total button works with the total button on the previous screen. If a total button is turned on for an amount
or quantity field on the previous screen, a total may be calculated for each entry of a sort field. The total is at
the end of each entry and serves as a subtotal to the report total. If the previous screen does not contain any
totaling fields, these entries are null.
If a box should be drawn around each new section of the sort field, select the box field. The box field on the
prior screen must also have been selected.
A blank line or new page may occur between each occurrence of a sort field.
Hit the Next Screen button to continue.
2005 SAP AG The SAP Developer Network: http://sdn.sap.com 1
A Primer for Queries: ABAP, SAP,
QuickViewer, and InfoSet Queries


On the sort levels, if the total or text button have been selected on the previous screen this screen will follow.
This screen allows the total text and the top text to be modified if needed. The <__>designates the size of
the field. In the example above, the company's four digit code (0110) would appear.

2005 SAP AG The SAP Developer Network: http://sdn.sap.com 1
A Primer for Queries: ABAP, SAP,
QuickViewer, and InfoSet Queries

Each line of detail created on a previous screen can be displayed differently. In this query we have
determined two detail lines per record. The fields for each line are listed on the bottom half of the screen.
The color for each line can be different. The descriptions for the colors may not make sense (headers in line 2
does not mean line 2 is a header), it is a color scheme name only.
A column header will be generated for the line if the "Header Line" button is marked. These headers can be
modified.
The reference field creates a link between the lines for printing reasons. In this example, line 1 is a header
record for the account and line two is the detail. If the account doesnt have any detail, the user does not want
to print the header line either. This creates a link between the two lines and line one would not print by itself.
Line 1 is dependent on line 2.
Blank lines may be inserted before or after each detail line. Enter the number of lines needed.
The page header button will print the last detail line from the previous page again. This is mainly used if
multiple lines of detail exist and the user would like to see what record the remaining lines of detail belong
with.
A new page may be specified for detail lines. This is not normally used.

The field output options screen allows each individual field to be formatted.
The length of the field may be changed for printing. The standard length appears under the STD column and
just to the right a new length for the query may be entered. Query does know the text fields are left justified
and will take the characters off the back and the numeric fields are right-justified and will take the characters
off the front. It will truncate if the field is too small.
2005 SAP AG The SAP Developer Network: http://sdn.sap.com 1
A Primer for Queries: ABAP, SAP,
QuickViewer, and InfoSet Queries

To specify a particular starting point for the field, enter the column space number in the position field. Query
will not allow overlapping fields. If a number is not specified, one space will be placed between each field. In
the example above, the account description will begin in column space number 15.
The unit field is only valid for amount and quantity fields. If the circle to the left is selected, the currency or unit
of quantity will appear to the left of the amount. The middle circle suppresses the currency or unit of quantity
from printing and the circle to the right will print to the right.
Each field may appear in a different color from the specified color on the line format screen. The color will be
for the entire column containing the field.
The template field will place a character in front of the field. This is only available on character and date fields.
Amount and quantity fields do not allow templates. When this option is selected, a screen will appear when
hitting enter and ask for the template character.
The last field on the right is a zero suppress option for amount and quantity fields. The amount is only printed
if it is not equal to zero.
Hit the "Next Screen" button to continue.

This is the column heading screen. At the top portion of the screen are the headings. To insert a line in the
headings, hit the F2 key on the keyboard. If a line is left blank, the system deletes the line.
To change the column heading for a field, double-click on the current heading. For example, to change the
account column heading, double-click on the word "Account." A screen will pop up and allow you to change
the description.
If the headings are modified and need to be changed back to the standard, Settings Standard
2005 SAP AG The SAP Developer Network: http://sdn.sap.com 1
A Primer for Queries: ABAP, SAP,
QuickViewer, and InfoSet Queries

Header will replace the modified headings with the standard header at the top of the screen.
Footers may also be added in the bottom portion of the screen.
This is the last screen to configuring a query. At this point the query may be saved and executed.
Executing the query does not automatically save the query!
Executing the ABAP/4 Query
Save the Query before executing. If something happens during execution, the query or any changes to the
query will be lost.
Hit the "Execute" button. The query may be executed from any screen within the query or at the ABAP/4
query initial screen.

The logical database selections are at the top of the screen.
The program selections are the fields specified by the query creator in the Fields Selection screen of the
query or in the functional area parameters and selection criteria screens. In this example, the amount field
was a parameter entered in the functional area. The last three fields were selected in the query.
Execute.
A screen print of the report is included.

2005 SAP AG The SAP Developer Network: http://sdn.sap.com 1
A Primer for Queries: ABAP, SAP,
QuickViewer, and InfoSet Queries


Ranked Lists in ABAP/4 Queries
ABAP/4 Query can create a ranking list, for example a listing of customers in order of sales volume. Because
the example is using general ledger accounts, the ranking will be for postings to an account.
To create a ranked list, hit the "Ranked List" button from any screen in a query.
2005 SAP AG The SAP Developer Network: http://sdn.sap.com 1
A Primer for Queries: ABAP, SAP,
QuickViewer, and InfoSet Queries


Select the order the fields are to appear across the page in the "No." Field.
Select the criteria for the ranking. This must be an amount or quantity field, so for this example there is only
one option.
The default for ranked list is descending. To change this to ascending, check the "Asc" box.
Specify the length of the field to be printed in the "Len" field.
The rounding unit for amount and quantity fields is the "Rnd" box.
The unit specified is used for conversion factors.
The "Text" column is for business graphics descriptions.
Once this screen is filled out, the ranked list is complete and ready to be executed. Headings may be
changed if necessary. Ranked list headings are maintained just like basic list headings.
If a basic list is also included in the query, the ranked list is shown below the basic list.
An example of the ranked list output is below.
2005 SAP AG The SAP Developer Network: http://sdn.sap.com 1
A Primer for Queries: ABAP, SAP,
QuickViewer, and InfoSet Queries


Using Report/Report Interface in ABAP/4 Queries
To drill down in ABAP/4 Query, use the report/report interface functionality within the query.
From any screen in the query: Goto Report Assignment.
The following pop-up box will appear.
2005 SAP AG The SAP Developer Network: http://sdn.sap.com 1
A Primer for Queries: ABAP, SAP,
QuickViewer, and InfoSet Queries


To insert the drill down report, hit the insert button on the pop up screen.
You may attach the following types of reports:
ABAP/4 Program
ABAP/4 Query
Transaction Code
Report Group from Report Writer / Painter


After hitting insert, another box will pop up. The default type of report is another query. To change this to
another type of report, hit the 'Other Report Type' button. A list of the possible report types will appear.
Double click on the type of report you wish to attach.
2005 SAP AG The SAP Developer Network: http://sdn.sap.com 1
A Primer for Queries: ABAP, SAP,
QuickViewer, and InfoSet Queries



nter in the appropriate report for your selection.
rt into the report assignments screen.

E
Hit the enter key.
The report will inse
2005 SAP AG The SAP Developer Network: http://sdn.sap.com 1
A Primer for Queries: ABAP, SAP,
QuickViewer, and InfoSet Queries


Hit the Save button.
Save the query.
To use the report/report interface in your query:
Execute the query.
Select the "Report Call" button. This will bring up a list of the attached reports. Select the one to execute.
What is an SAP Query?
With the advent of version 4.6, the SAP Query became available. It is based on the same principles and
components as the ABAP/4 Query with some following additions and differences.
The SAP Query uses as its data source InfoSets, which are the same concept as the Functional Areas of the
previous version of ABAP/4 query. As in ABAP/4 queries, users can create and execute queries only if they
are part of a User Group. Each user group needs to have access to at least one Infoset and the Infoset has a
more graphical design environment than the ABAP/4 query Functional area.
The fields of the InfoSet are grouped into an element called field groups which were referred to as functional
groups in the ABAP/4 Query. These are logical groupings only to provide a more intuitive access to groups of
fields or groups of functional areas for the end users selection ease.
2005 SAP AG The SAP Developer Network: http://sdn.sap.com 1
A Primer for Queries: ABAP, SAP,
QuickViewer, and InfoSet Queries

An additional attribute of SAP queries is the designation of two different query areas: global query areas and
standard query areas. Global query areas are client-independent and are transported automatically. In the
standard area, all query objects are client-dependent and are not connected automatically to the transport
system.
SAP Queries use a graphical design interface called the Query Painter.
A SAP Query utilizes ranked, statistical, and basic lists and also allows you to define local fields within the
query as an enhancement to the fields available through the InfoSet.
By using the Query Painter, you can design control level processing for sorted fields and produce totals for
each control level. There is also an option for counting the fields, so items can be automatically numbered.
The graphical Query Painter supports header and footer definition, defining output formats for lines and
individual fields, column headers to override system defaults and also editing output lengths and positions of
fields.
One of the biggest advantages of the Query Painter as opposed to the alphanumeric environment of the
ABAP Query is drag and drop to list edit. You can easily change field sequence and also delete fields by
dragging them to a trash can icon.
SAP Queries also support Report/Report Interface, which means that one can invoke a secondary query with
a double click on a line of output in the main report When double-clicking, all fields of the lines that you
selected by double-clicking are transferred to the selection screen of the second query, thereby enabling
elegant drill-down capabilities.
What is a QuickViewer Query?
The QuickViewer is a Query tool that was introduced in release 4.6. The primary purpose was to create ad
hoc queries with little administrative effort. The QuickViewer bypasses the need for a functional area, Infoset,
or user group but it still incorporates the 3 basic query generation steps of defining a data source, defining the
list layout and selection criteria and defining the output list format. It incorporates the use of the Query
Painter, so from a graphic perspective is easier to use than ABAP query. The data source of a QuickView can
be a table, tables (join), view, logical database or InfoSet. The QuickViewer is accessed with transaction code
SQVI. It contains fairly good online documentation and has an embedded task list that works as a tutorial and
guide through the steps of creating a query. QuickViews are user specific, as opposed to ABAP queries or
SAP queries, which could be connected to the change and transport system.
What is an InfoSet Query?
Infoset Queries resemble SAP Queries in many ways. The SAP Query and the InfoSet Query both require
the definition of a user groups and both use an InfoSet as a data sources so administrative steps are
necessary for both tools. The use of user groups is different in the InfoSet Query though, as a user is not
assigned to a user group directly, but rather via a role. Each person can have various roles but be assigned to
only one user group per role. InfoSet queries can be initiated from role menus. The concept actually restricts
the visibility and availability of data sources for a particular user by linking to role-based authorization
checking concept. InfoSet queries can be released for Web Release but the source InfoSet must have an
authorization group associated with it as a pre-requisite.

2005 SAP AG The SAP Developer Network: http://sdn.sap.com 1
A Primer for Queries: ABAP, SAP,
QuickViewer, and InfoSet Queries

Query Tools Summary Matrix

A
B
A
P

Q
u
e
r
y

S
A
P

Q
u
e
r
y

Q
u
i
c
k
V
i
e
w
e
r

I
n
f
o
S
e
t

Q
u
e
r
y

Necessity of Administrative Steps (User Groups/InfoSets) Yes Yes No Yes
Supports Graphical Query Painter No Yes Yes Yes
Views Live Data Yes Yes Yes Yes
Transportable Yes Yes No Yes
Supports Local Field Creation Yes Yes No No
Supports Statistical and Ranked lists Yes Yes No Yes
Supports Hierarchical Lists Yes Yes No No
Supports Report/Report Interface Yes Yes No Yes
Query Specific Authorization Checks Yes Yes No Yes
Drag and Drop Capability No Yes Yes Yes
Background or batch job execution Yes Yes No Yes
Author Bio

When not actively engaged as a grandmother and mother, Marilyn Pratt serves as a Community Manager of
the SAP Developer Network and can be found lurking in the ABAP forum, XI pages, and other technology
areas.

2005 SAP AG The SAP Developer Network: http://sdn.sap.com 1

Das könnte Ihnen auch gefallen