Enter word you want search.

วันศุกร์ที่ 30 ตุลาคม พ.ศ. 2552

Chapter 3. Creating Basic Reports with the SAP Query Tool


Creating a Basic List Query by Using the SAP Query Tool

To create a basic list query by using the SAP Query tool, follow these steps:

1. Log in to your SAP client where your query reports will be created. (Best practice dictates that they be maintained in your live Production client.)

2. Navigate to the Maintain Queries Initial screen by using the transaction code /nSQ01. Beginning with R/3 release 4.6A, SAP offers a graphical version of the SAP Query tool, called the Graphical Query Painter; if you have not used the SAP Query tool, the Graphical Query Painter is set as your default. To turn off the Graphical Query Painter and learn to create easy step-by-step reports by using the SAP Query tool, select Settings, Settings and then deselect the Graphical Query Painter check box.

3. The title bar lists the query group you are currently in. For example, your title bar might read Query from User Group ZTEST: Initial Screen. If you are assigned to multiple query groups, press F7 to see a list of all of them.

4. As discussed in Chapter 1, "Getting Started with the SAP R/3 Query Reporting Tools," it is recommended that you create your queries in the standard query area. Ensure that you are in the standard query area by selecting Environment, Query Areas and then selecting Standard Area.

5. In the Query field, type DLS_QUERY_01 where DLS is your initials) as the name for the query you are creating, and then click the Create button (see Figure 3.1).


Figure 3.1. The main screen of the SAP Query tool lists all the queries available in the designated query group.


6. The InfoSets of User Group ZTEST window appears, listing all the available InfoSets (that is, data sources) for your query group. Because you created only one (in my example, I called it ZTEST), in Chapter 2, "One-Time Configuration for Query Tool Use," it will be the only one listed. Select the InfoSet you created (ZTEST, in my example) and then click the green check mark button.

7. The Create Query Title Format screen appears. This screen allows you to save the basic formatting specifications for your query, including the name (title) and any notes you want to store for the query. The only required field is the Title (long report description). For this example, fill in only the Title field, as shown in Figure 3.2, and then click Save. (For my example, I used the title (DLS) SAP Query Exercise #01.)


Figure 3.2. The Application toolbar for the SAP Query tool contains navigational arrows that permit you to navigate between the screens of the query.


8. Navigate to the next screen in the SAP query creation process by selecting the Next Screen (white navigational arrow) button from the Application toolbar. (You can use the navigational arrows to navigate between the different screens of the SAP Query tool.) The Select Field Group screen appears, listing all the Field groups available within your InfoSet. Figure 3.3 shows this screen with the field groups Flight Schedule [SPFLI], Flight Demo Table [SFLIGHT], and Flight Booking [SBOOK] listed.


Figure 3.3. All the field groups listed at the top right of the InfoSet screen during configuration of the InfoSet are listed on this screen.


9. Place a check mark next to each field group from which you want to include fields in your report. Navigate to the next screen in the SAP query creation process by selecting the Next Screen (white navigational arrow) button on the Application toolbar. The Select Field screen appears, showing a list of all the available fields in the selected field groups.

10. Place a check mark next to each field that you want to include in your report. You can use the Page Up and Page Down keys to navigate between all the fields (see Figure 3.4). Select the Next Screen (white navigational arrow) button from the Application toolbar to open the Selections screen, which lists all the fields you have selected.


Figure 3.4. All the fields listed in the field groups at the top right of the InfoSet screen during configuration are listed here.


11. If desired, add any of the fields to the selection screen that will be presented when you execute your report. You can add a field to the Selections screen by placing a check mark next to each one (see Figure 3.5).



Figure 3.5. Having fields available on the report's selection screen gives you the ability to specify your report output upon execution.


12. Click the Basic List button from the Application toolbar to create an SAP basic list query. The Basic List Line Structure screen appears, showing a list of the fields you selected to include in your report.

13. For each field, specify the line and sequence number as you want them to appear on your report. Also use this screen to indicate sort order, totals, and counts, if needed. Start by entering the line and sequence numbers, like the ones shown in Figure 3.6.


Figure 3.6. Basic output options are defined on the SAP Query tool Basic List Line Structure screen.

Note

You can use Figure 3.6 as follows:
  • Line column The values in this column correspond to the line numbers the fields will appear on in the report.
  • Sequence column The numbers in this column determine the order of the fields for the line.
  • Sort column This column dictates the order in which the data will be sorted.
  • Line Structure box After you click the Save button, a preview of the format appears in the Line Structure box at the bottom of the screen.
14. For this example, proceed directly to the report by pressing F8, which causes the report to execute.

15. As with almost all other reports in SAP, when you execute this report, you see the report's selection screen. Specify any criteria for the output of your report. Notice that any fields indicated on the Selections screen are included on your selection screen, under the heading Program Selections (see Figure 3.7).

Figure 3.7. Selection screens enable you to further specify
output.


16. Select the F8 Execute button on your Application toolbar (it looks like a clock) to display your finished report. Your report output appears; it should look similar to what is shown in Figure 3.8. (Keep in mind that the actual values vary by organization: The output of the report corresponds to the specification entered on the Basic List Line Structure screen.)

Figure 3.8. In SAP 4.6 and higher, by default, your report displays in the SAP List Viewer.


Reviewing the Options on Each of the Five Basic Screens

The Title, Format Screen

The Title, Format screen, shown in Figure 3.9, is where you insert the basic data about your report, including its title and the format in which you want it displayed. The Title, Format screen stores the basic report processing options for your report. For organizational purposes, it is a good idea to enter the name of the user who created the report in the Notes section of this screen. The following sections describe the options available on this screen.

Figure 3.9. The Title, Format screen.


Select Field Group Screen

In the Select Field Group screen, shown in Figure 3.10, a list of all the available field groups is populated during the creation of the InfoSet. (See Chapter 2 for more information.) This example has only three field groups; however, some logical databases contain hundreds. You place a check mark next to any field group that contains fields you want to include in your SAP query.

Figure 3.10. All the field groups listed at the top right of your InfoSet screen during configuration of the InfoSet are listed on this screen.


The Select Field Screen

In the Select Field screen, shown in Figure 3.11, a list of all the available field groups populated during the creation of the InfoSet is expanded to display all the fields contained within them. You place a check mark next to any field you want to include in your SAP query.
Figure 3.11. All the fields listed in the field groups at the top right of your InfoSet screen during configuration are listed here. This screen is also used for advanced functions covered later in this book.


The Selections Screen

In the Selections screen, shown in Figure 3.12, a list of all the previously selected fields appears. You place a check mark next to any field that you want to include on the Selections screen that appears upon report execution. This gives you the option to specify particular data.


Figure 3.12. Having fields available on your report's selection screen gives you the ability to specify your report output by varying your input prior to report execution.

For example, in Figure 3.12, I selected that I wanted the Airfare, Maximum Capacity, and Weight of Luggage fields to appear on my report's Selections screen. This means that when I execute my report and see the Selections screen, those three fields will be listed there, under the heading Program Selections. Having them there allows me to run the report based on specific airfares, maximum capacity, or weight of luggage. (For example, I could run a report that contains a list of flights between $50 and $200.)


The Basic List Line Structure Screen

By default, only the first few selected fields of your report appear on the Basic List Line Structure screen, shown in Figure 3.13. They are all there, but with the default view, they are not all visible. You can use the Page Up and Page Down buttons on the right side of the screen to navigate between them, or you can select the Without Explanation button (at the bottom left of the screen) to view more fields on a single screen. The Basic List Line Structure screen lists all the fields you want to include in your output. You can have fields listed here for sorting purposes but not included in the output by simply leaving the Line and Sequence fields blank.


Figure 3.13. This is the screen where you dictate how you want your report to appear, including sequence and sorting specifications.

Chapter 2. One-Time Configuration for Query Tool Use


This chapter covers everything you need to know to make the SAP R/3 Query family of tools ready for use. The steps for the configuration are broken down in such a simple and easy-to-use format that anyone can perform them. However, the decision to use a particular tool or tools and the administrative methodology that will be put into place to use the tools requires deeper consideration.

Before you dive in and begin performing the one-time configuration that is necessary before you can use the SAP Query reporting tools, you should review Chapter 1, "Getting Started with the SAP R/3 Query Reporting Tools." As discussed in Chapter 1, the SAP R/3 Query tools (SAP Query, InfoSet (Ad Hoc) Query, and QuickViewer) are built on a foundation of four main components:
  • Query areas
  • Query groups
  • InfoSets
  • Administrative decisions (which are company-specific)
This chapter covers how to configure query groups and InfoSets so that you can begin using the Query family of tools.


Steps in Configuring the Query Tools


After you have made the administrative decisions described in Chapter 1, you can perform the one-time configuration of the Query tools in four quick and easy steps:

1. Create query groups.

2. Assign users to query groups.

3. Create InfoSets.

4. Assign each InfoSet to a query group.


Step 1: Create Query Groups

To create a new query group, you perform the following steps:

1. Log in to your SAP client where your query groups will be maintained. (As noted in Chapter 1, best practice dictates that they be maintained in your live production client.)

2. Navigate to the User Groups: Initial screen by using the transaction code /nSQ03, as shown in Figure 2.1


Figure 2.1. SAP query groups are created and modified using the User Groups: Initial screen.


3. Ensure that you are in the appropriate query area by following the menu path Environment, Query Areas and selecting Standard Area. (Best practice dictates that you maintain query areas in the standard area, as discussed in Chapter 1.

4. Type in the name for your query group in the User Group field. (For purposes of this example, I'm naming mine ZTEST.) Then click the Create button.

5. When a dialog box appears, asking you to provide a description for your query group, type Test Query Group 1 and then click the green checkmark Save button.


Step 2: Assign Users to Your Query Groups

To assign users to a query group, perform the following steps:

1. Click the Assign Users and InfoSets button.

2. Type in the SAP user IDs of any users you wish to include in your test group, making sure to include your own user ID (see Figure 2.2).


Figure 2.2. Input the SAP user IDs for any user you wish to belong to the query group.


3. Click the Save button on the toolbar. A message appears in your SAPGUI status bar, saying "User group ZTEST saved."

Now that you have a query group created, the next step is to create an InfoSet.


Step 3: Create InfoSets

You create InfoSets (known as functional areas in versions of SAP prior to version 4.6) on the InfoSet: Initial screen, shown in Figure 2.3. As stated in Chapter 1, an InfoSet is basically the data source from which you get the data to use in your reports. You can picture an InfoSet as an organized container that holds all your stuff. InfoSets can be built on a variety of different sources, but the most common is the use of a logical database.

Figure 2.3. A list of all previously created InfoSets is displayed on the InfoSet: Initial screen.


To create a new InfoSet, you perform the following steps:

1. Log in to your SAP client where your InfoSets will be maintained. (As noted in Chapter 1, best practice dictates that you maintain them in your development client.)

2. Navigate to the InfoSet: Initial screen by using the transaction code /nSQ02 (see Figure 2.3).

3. Ensure that you are in the appropriate query area by selecting Environment, Query Areas and then selecting Standard Area. (Best practice dictates that you maintain query areas in the standard area, as covered in Chapter 1.)

4. Type in a name for your InfoSet. (For purposes of this example, I'm naming mine ZTEST.) Then click the Create button.

5. On the InfoSet: Title and Database screen, type an InfoSet description in the Name field. (For purposes of this example, I'm naming mine Test InfoSet 1.)

6. On the InfoSet: Title and Database screen, select the Logical Database radio button and select or input logical database f1s in the field to its right (see Figure 2.4), and then press Enter.

Figure 2.4. There are several hundred logical databases to choose from.


A Change InfoSet screen, similar to the one shown in Figure 2.5, appears. The Change InfoSet screen displays a list of all tables available in the selected logical database for your InfoSet. The logical database selected, F1S, contains three test tables, called SPFLI, SBOOK, and SFLIGHT, which correspond to the three field groups listed at the top right. The field groups are what the end users see when they are creating reports using the SAP Query reporting tool.


Figure 2.5. The Change InfoSet screen is divided into three sections.


7. To view the fields in each of the three tables, use the expand subtree button next to each table name. The table selected expands and displays the fields underneath, as shown in Figure 2.6.


Figure 2.6. The left side of the screen lists the tables and fields, and the right displays the field groups.


8. Assign fields to the field groups (shown on the top right of the screen) within the InfoSet. These field groups will display in the SAP Query tool during reporting. Only the fields that you include in your field groups will be available for field selection in the SAP Query tool that uses this InfoSet as its data source. By default, these field groups are empty.

9. Place your cursor on the first field group, Flight Schedule, and double-click to highlight that field group as the selected field group. Next, select fields from the left side of the screen from the Flight Schedule table and add them to the Flight Schedule field group by placing your cursor on a field on the left side of the screen, right-clicking, and selecting the option Add Field to Field Group (see Figure 2.7).


Figure 2.7. You should only add fields to their corresponding field groups (for example, Flight Schedule table to Flight Schedule field group).


10. When the field you just added to the Flight Schedule field group appears at the top right of the screen, add fields to your selected functional group by following the procedure outlined in step 9. Be sure to add fields to the appropriate field groups. For example, fields in the Flight Schedule table should be added to the Flight Schedule field group, and fields from the Flight Booking table should be added to the Flight Booking field group.

11. After you have added a series of fields to your field groups, click the Save button on the toolbar. A message appears in the status bar, saying that your InfoSet was saved.

12. Generate the InfoSet by clicking the Generate button (the red beach ball) on the Application toolbar. A message appears in the status bar, saying that the InfoSet was generated.

13. Exit the Change InfoSet screen by clicking the green back arrow.


Step 4: Assign Each InfoSet to a Query Group

You have now created a Query group, assigned users to it, and created an InfoSet. The last step before you begin creating reports is to assign your InfoSet to your Query group. This is an easy task:

1.On the InfoSet: Initial screen (which you reach by entering transaction code //nSQ02), make sure your InfoSet name (in my example, ZTEST) is present in the InfoSet text box, and click the User Group Assignment button.

2. In the InfoSet: Assign to User Groups screen that appears, highlight your query group (in my example, ZTEST) by selecting the gray button to the left of it, and then click the Save button. A message appears in the status bar, saying that the assignment of InfoSet has been saved.

3. Exit the InfoSet: Assign to User Groups screen by clicking the green Back arrow.You are now ready to begin creating reports with the SAP R/3 Query reporting tools. Chapter 1, "Creating Basic Reports with the SAP Query Tool," describes how to do so using SAP Query.

Chapter 1. Getting Started with the SAP R/3 Query Reporting Tools



The SAP R/3 Query Reporting Tools


In addition to these four main avenues, SAP comes preinstalled with the following end-user reporting tools:

  • SAP Query
  • InfoSet (Ad Hoc) Query
  • QuickViewer

Note

The SAP R/3 Query tools are SAP Query, QuickViewer, and InfoSet (Ad Hoc) Query. When I refer to the SAP Query tool, I am referring to the individual SAP Query tool, and when I refer to all three of the tools, I use the term SAP R/3 Query tools. This may appear a bit confusing at first, but you will get the hang of it as you move along.
The SAP Query Tool

The SAP Query tool, known as the ABAP Query tool in earlier versions of SAP, is delivered with the SAP R/3 system. End users can use this tool to quickly and easily create reports from data stored in the SAP R/3 database. This tool can be used in any application module in SAP. Its easy-to-use format simplifies the report creation process. The SAP Query tool includes basic and advanced features for every level of end user. The SAP Query tool offers a broad range of ways to define output and create different types of reports, such as basic lists, statistics, and ranked lists. This tool can be used in a basic or graphical mode.
The InfoSet (Ad Hoc) Query Tool

Unlike the SAP Query tool, which is a complete reporting solution, the InfoSet Query tool is designed for basic users to retrieve simple, single-use lists of SAP R/3 data. In SAP 4.6, the Human Capital Management module reporting tool called the Ad Hoc Query tool was combined with the technology of the SAP Query tool and made available for all modules; its new name is the InfoSet Query tool (although it is still referred to as the Ad Hoc Query tool when executed for human resources reporting). This book refers to it as the InfoSet (Ad Hoc) Query tool.

Unlike with the SAP Query tool, all query information, including the selection criteria, for InfoSet Query tool reporting is available on a single screen. You can use the InfoSet (Ad Hoc) Query tool to quickly answer simple questions or to create a comprehensive report for printing or downloading to your PC. A user can use the InfoSet (Ad Hoc) Query tool to pose questions to the SAP system and receive real-time answers.
The QuickViewer Tool

The QuickViewer tool that is delivered with a SAP 4.6 system is a WYSIWYG ("what you see is what you get") utility for quickly collecting data from an R/3 system. The QuickViewer tool is actually a variant of the robust SAP Query tool that is designed for new or occasional users or for single-use data inquiry reports. You can use this tool to create reports referred to as QuickViews. To define a report with the QuickViewer tool, you simply enter texts (titles) and select the fields and options that define the QuickView. QuickViews cannot be exchanged among users, but they can be converted to reports to be used with the SAP Query tool.


How the SAP R/3 Query Tools Work

Query tools are based on the foundation of the SAP R/3 database. Historically, the primary method of creating reports in SAP was by using the ABAP Workbench and writing code in the language of ABAP. Specially trained programmers could write a long series of lines of code in an ABAP editor to retrieve information from the database, compute relationships, configure security, design selection screens, and present data in a particular arrangement. The skill set for ABAP programming is challenging to learn and usually requires experience in each application area of SAP for which programming will occur. For example, an ABAP programmer with experience in the Financials module would require special training to change functions and create reports in the Sales and Distribution area. Because these programming skills are substantial, SAP created the Query family of tools so that end users could pick and choose the fields they want to include in their reports and, behind the scenes, SAP would handle all the technical details. Figure 1.1 is a diagram that shows the foundation of the SAP Query tools.


Figure 1.1. An overview of the technical aspects of the SAP R/3 Query tools.
As described in the following sections, the SAP R/3 Query toolsSAP Query, InfoSet (Ad Hoc) Query, and QuickViewerare built on the foundation of four main components:
  • Query areas
  • Query groups
  • InfoSets
  • Administrative decisions (which are company-specific)
Query Areas
Query areas (known as application areas in versions of SAP earlier than 4.6) contain SAP Query elements, queries, InfoSets, and query groups. SAP has two distinct query areas:
  • Standard Standard query areas are client-specific. That is, by default, they are available only within the client in which they were created. For example, if they were created in the live production client, they would exist only in the production client. Transport of query objects created in the standard area can be accomplished between multiple clients on the same application server.
  • Global Queries designed in the global query area are used throughout the entire system and are client-independent. In version 4.6, SAP delivers many of its standard reports in the SAP Query global query area. These queries are also intended for transport into other systems and are connected to the ABAP Workbench.
Query Groups
Query groups were known as user groups in versions of SAP prior to version 4.6. A query group is a collection of SAP users who are grouped. A user's assignment to a query group determines which queries he or she is allowed to execute or maintain. In addition, it designates which InfoSets (that is, data sources) the user has access to work with. Basically, query groups give a user access to create, modify, and execute reports in a certain area within R/3. For example, you could create a query group for the Finance department that would house your financial users, or you could create a query group for the Human Resources department that only members of the Human Resources department would belong to. Using query groups is an easy way to group and segregate reports and users.
Query groups, which are often maintained by a system administrator, are created on the User Groups: Initial screen, which you can find by using the transaction code /nSQ03.
Users can belong to multiple query groups and might, under certain circumstances, copy and execute queries from other query groups (if the permissions are the same). Any user within a query group has authority to execute queries that are assigned to it, but only users with the appropriate authorization can modify queries or define new ones. Users are not permitted to modify queries from other query groups.
InfoSets
InfoSets, known as functional areas in earlier versions of SAP, are areas that provide special views of logical databases and determine which fields of a logical database or data source can be evaluated in queries. That is, an InfoSet is basically the data source, from which you get data to use in reports.
InfoSets can be built on a variety of different sources, but the most common is the use of an SAP logical database. Remember that writing reports without Query tools requires a programmer to write code that goes into the main R/3 database and retrieves the records it needs, and that is no easy skill. SAP delivers logical databases, which are rational prearranged groupings of data from multiple related indexed tables. SAP places all the fields you want to report from in a nice container from which you simply select the fields you want to include in your report.