You are on page 1of 35

ABAP Query

Creation

04/30/2006 Development Team Page 1


ABAP Query

The application SAP Query is used to create lists not already


contained in standard SAP. It has been designed for users with little
or no knowledge of the SAP programming language ABAP.

ABAP Queries should be created for enterprise reports. Single user


or simple business unit reports should be created by the end users
using SAP Quick Viewer.

04/30/2006 Development Team Page 2


ABAP Query Components

An ABAP Query is comprised of 3 components:

InfoSets - InfoSets determine to which tables, or field


within a table, a query can refer. InfoSets are
usually based on table joins or logical databases.
These should be created with sharability in mind.
User Groups - The user group allows you to to specify the
users who are authorized to run and/or
create/change queries under that user group.
Queries - Formatting the data identified in the InfoSet to
create the desired report.

04/30/2006 Development Team Page 3


Standard vs. Global Areas

ABAP query components can be created in either the standard


area or global area:
Standard Area - Allows for creation of client-dependent objects
that have to be exported to a transport and then imported into
each required client.
Global Area - Allows for creation of client-independent objects
that get transported via the normal transport process. A
transport is required on save of an object.

NOTE: Global Area will be the Client standard since query


objects need to be client-independent and should be created as
permanent efficient objects.

04/30/2006 Development Team Page 4


Standard vs. Global Areas

To ensure you are in the Global Area, each of the query


transaction codes will show the following at the top of the
screen:

Query area Global Area (Cross-client)

If it does not, you are in the Standard Area. To switch to the


Global Area, select from any of the query transactions:

Environment > Query areas

A pop-up box will be displayed. Choose Global Area (Cross-


client).

04/30/2006 Development Team Page 5


InfoSet - Creation
Menu Path: Tools > ABAP Workbench > Utilities > SAP Query > InfoSets
Transaction: SQ02

Enter your InfoSet


name and hit the
button.

04/30/2006 Development Team Page 6


InfoSet - Data Source - Logical Database
Logical databases have already been set up and should be used if they
contain the appropriate data. The table joins have already been done.
Enter your description and your data source.

04/30/2006 Development Team Page 7


InfoSet - Data Source - Logical Database
To find the available databases, select the possible entries on the
Logical database field and enter a required table name.
Possible entries will be displayed and select one.

Select the nodes (tables of the logical database) you require.

04/30/2006 Development Team Page 8


InfoSet - Data Source - Logical Database
To display the structure of the logical database, select the magnifying
glass next to Logical database field on the InfoSet: Title and Database
screen.

04/30/2006 Development Team Page 9


InfoSet - Data Source - Table Join
A table join data source should be used if no logical database is available.
Enter your description and your data source.

04/30/2006 Development Team Page 10


InfoSet - Data Source - Table Join
Select to insert another table.
A pop-up will appear, enter the table name
The system will automatically propose joins.

Press the Green arrow to back out.


The pop-up on the right will appear, select include key fields.
04/30/2006 Development Team Page 11
InfoSet - Data Source Data Retrieval Program
It is possible to create an InfoSet using data retrieval by either an internal
or external program.

A data structure is required that may need to be created custom if an


existing structure does not suffice.

An internal program allows you to create the code within the InfoSet to
populate the specified structure.

Both of these methods have not been used by Client and would require
further investigation and standardization.

04/30/2006 Development Team Page 12


InfoSet Additional Tables, Structures, and Fields
Additional tables, structures, and fields allow you to enhance the selected
data source. They have two common features:

The point (event) at which SAP Query reads an additional table or


performs a calculation on an additional field depends on the logical
database table, since the associated ABAP code becomes part of the
GET event processing that table.

Any query for the InfoSet can address both additional fields and
additional table fields, provided they are assigned to a field group of that
InfoSet.

04/30/2006 Development Team Page 13


InfoSet - Further Code
InfoSet functionality to generate further code makes additional tables,
structures, fields, parameters and selection criteria more flexible.
These options generate ABAP code for all queries of an InfoSet, but this
is transparent to the end-user. The coding areas are as follows:

DATA for global data declarations.


INITIALIZATION for initializing data fields.
AT-SELECTION for selection screen processing.
START-OF-SELECTION which precedes the first database access.
GET/GET Late for these events for a logical database table.
Record Processing for processing individual records for non-logical databases.
Free Coding for forms routines at end of the program.
END-OF-SELECTION either before or after output of the list.
TOP-OF-PAGE for just before the instructions for output of the page header.

04/30/2006 Development Team Page 14


InfoSet - Further Data Information
When using a logical database, the additional tables feature can be
used to join tables not in the logical database, but only at an existing
table level. Selects can also be done in the coding section and data
moved to additional fields or additional structures.

When using table joins, a limitation is that only one left outer join can be
used per InfoSet. Again the coding section can be used to select other
tables, but this method can only be used to add additional fields and not
additional records to the relational structure of the join statement.

04/30/2006 Development Team Page 15


InfoSet - Selecting Fields for Field Groups
The left part of the screen shows all fields available in the database
tables. The right side shows what fields have been selected for this
InfoSet. Move all fields required for the query into the proper field
group.

Press to generate and save the InfoSet.

04/30/2006 Development Team Page 16


User Group - Creation
Menu Path: Tools > ABAP Workbench > Utilities > SAP Query > User
Groups
Transaction: SQ03

Enter your User


Group name
and hit the
button.

Enter a description
and hit save.

You will be prompted


for a transport.

04/30/2006 Development Team Page 17


User Group Assign Users
Press the to assign users to your User Group.
Select the checkbox next to the user name if you want them to create or
change queries.
Press save and green arrow back.

04/30/2006 Development Team Page 18


User Group Assign InfoSets
Press the next to the InfoSet field on the main screen. Be
sure your InfoSet name is in the field.

Select your User Group name and press save. Your User
Group is now assigned to your InfoSet.
04/30/2006 Development Team Page 19
Query - Creation
Menu Path: Tools > ABAP Workbench > Utilities > SAP Query > Queries
Transaction: SQ01

Select your user group.

Enter your Query


name and hit the
button.

Select an InfoSet.

Enter a description
and hit save.

You will be prompted


for a transport.

04/30/2006 Development Team Page 20


Query - Creation
Enter your Query description, list and output format. Hit to continue.

Use Notes to document


the Remedy ticket
number, date of
creation, and brief
description.

Enter CUS&STANDARD
as the standard
variant to be used
by this query. The
naming convention
of CUS& allows this
to be transported.

04/30/2006 Development Team Page 21


Query Selecting Fields
Select the field groups you want to use in this Query.
Select the fields and selection criteria.

04/30/2006 Development Team Page 22


Query Graphical Query Painter
Select a report type and the Graphical Query Painter:
Basic List Simple Reports
Statistics Reports with statistical functions such Avg, %.
Ranked List Analytical Reports

04/30/2006 Development Team Page 23


Query Graphical Query Painter

04/30/2006 Development Team Page 24


Query Graphical Query Painter
Select or double-click the fields from the left to move to
your report.
Press save and test to execute your report.

04/30/2006 Development Team Page 25


Query Report Assignment
Report Assignment allows you to drill into another report or transaction.
Navigate to Query > Change >
Goto > Report Assignment.

Click on Insert Row.


To select an ABAP
Query, check Global
area, enter User Group,
Query, and Variant.

04/30/2006 Development Team Page 26


Query Report Assignment
To drill into another transaction:
Click on Other report type > Select TR.

Enter a transaction code.

To transport a report
assignment, click on
the transport button
and include in your
query transport.

04/30/2006 Development Team Page 27


Query Transaction Code Creation
To create a transaction code for your query use transaction SE93:

Enter a transaction code. Typically it


would be named with Z plus the domain
name plus _ plus a short name.

Enter a short text which would


typically be the Query Title with
(AQ) behind it for clarification.

Select Transaction with


paramters (parameter
transaction).
04/30/2006 Development Team Page 28
Query Transaction Code Creation
To create a transaction code for your query use transaction SE93:
Enter START_REPORT as the
Transaction and check the Skip initial
screen and Inherit GUI attributes boxes.

Enter the above screen fields and


values where EXTDREPORT is the
Query name, VARIANT is the starting
variant name (optional), and REPORT is
the user group (1st twelve characters)
plus G for global area.
04/30/2006 Development Team Page 29
ABAP Query

Standards

04/30/2006 Development Team Page 30


Standards - General

Any AD-HOC reporting by the end user or domain teams should be done
via SQVI (Query Quick Viewer).

All other queries are intended for wider distribution and/or frequency,
therefore these should be developed as permanent efficient development
objects.

All query objects will be developed in the Global Area and will be
transported via the standard transport process.

All development should be done in DEV and access to SQ01, SQ02, and
SQ03 should not be required in QR or PR.

Transaction codes would be created for all of these objects as that would
be the only means to execute these queries.

04/30/2006 Development Team Page 31


Standards - Ownership
SQ01 Query Maintenance These objects may be created by the Development
Team, but would be ultimately owned by the Functional Domain, using existing
InfoSets.

SQ02 InfoSet Maintenance These objects would be owned by the


Development Team and would be developed based on requirements from the
Functional Domains. Key Functional Domain users may create these with
Development Team review and approval.

SQ03 User Group Maintenance These objects would be owned by the


Functional Domains.

SE93 Transaction Codes for ABAP Queries These may be created by the
Development Team, but would be ultimately owned by the Functional Domain.

Non-conforming objects will be owned by Client group that created them until they
are converted to comply with current standards.

04/30/2006 Development Team Page 32


Standards Naming Conventions
All objects will begin with Z plus the Functional Domain plus - where applicable (i.e. ZSD_).
See additional requirements below:

Queries These objects should have a specific name to match the title of the Query (i.e.
ZSD_CUST_CL for Customer Credit Limit Rep).

InfoSets These objects should be created to cover generic table accesses and should be
named as such (i.e. ZSD_CUST_MSTR).

User Groups There should be one main user group for each Functional Domain (i.e. ZSD)
for general reports. Subgroups for specialty users should be named as the user group plus
the _ and a short name (i.e. ZSD_VC).

Tcodes These should named based on Functional Domain preference which could either
be a sequential numeric or significant short name (i.e. ZSD_001 or ZSD_CUSMST).

Variants All queries requiring a variant should have a standard variant created named
CUS&STANDARD to set defaults and hide fields as required for all users. SAP only allows
variants created with the prefix CUS& to be transported in the global area. User specific
variants should be created in Production.
04/30/2006 Development Team Page 33
ABAP Query

Clean Up

04/30/2006 Development Team Page 34


ABAP Query Clean Up
User groups will need to be set up in the global area by the Functional
Domains if they do not already exist, complying with naming conventions.

All new query objects will be created using the new standards and
conventions.

As existing objects are modified, they would need to be converted to


conform to the existing standards and conventions. InfoSet Maintenance
allows for conversion of objects from the Standard Area to the Global Area.

Unneeded Query objects should be cleaned up by the creating Client


group, whether it be a Functional Domain or the Development Team.

An on-going effort should be put forth to ensure clean-up of all query


objects prior to the upgrade, if possible.

04/30/2006 Development Team Page 35

You might also like