Creating A Basic List Query By Using 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.

2.

Navigate to the Maintain Queries Initial screen by using the transaction code /nSQ01. 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 them all.

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.

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, ZTEST) in Chapter 2, "One-Time Configuration for Query Tool Use," it is 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 Title (long report description). For this example, fill in only the Title field and then click Save. (For my example, I used the title (DLS) SAP Query Exercise #01.)

8.

Navigate to the next screen in the SAP query creation process by selecting the Next Screen (white navigational arrow) button on 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. (In my example, the field groups Flight Schedule [SPFLI], Flight Demo Table [SFLIGHT], and Flight Booking [SBOOK] are listed.)

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. Select the Next Screen (white navigational arrow) button on the Application toolbar to open the Selections screen, which lists all the fields you have selected.

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.

12.

Click the Basic List button on the Application toolbar to create an SAP basic list query. The Basic List Line Structure screen appears, showing a list of the fields that 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.

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.

16.

Select the F8 Execute button on your Application toolbar (it looks like a clock) to display your finished report. Your report output appears. (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.)

Query Maintenance Functions

Table A.1 provides detailed descriptions of each of the output format options.

Table A.1. SAP Query Reporting Output Options

Option

Description

SAP List Viewer

When you select this option, your list is not displayed onscreen in the normal form when the query is processed. Instead, the first sublist is transferred to the SAP List Viewer directly. You must be able to transfer this first sublist (it must be either a single-line basic list, a statistic, or a ranked list). This is the default selection.

ABAP List

When you select this option, the report appears in SAP as a basic list, without any formatting or fancy Microsoft Excellooking features. This was the format of all standard SAP Query tool reports in versions earlier than SAP 4.6C.

Graphic

This function allows you to display the information from your list by using SAP Business Graphics. In contrast to the other functions described in this table, the Graphic function can handle an extract from only one column of your sublist, and the column must contain numeric values. In addition, your SAP system has to have Business Graphics enabled.

ABC Analysis

You can use the ABC Analysis function for any single-line basic list, all statistics, and any ranked list that contains at least one numeric field.

Executive Information System (EIS)

This function provides a link to the Executive Information System (EIS). It transfers the data in your query to the EIS database via an interface so that you can perform further analyses. When you activate this function, you specify various options or storing the data in a dialog box.

File Store

When you select this option, the list is not displayed onscreen when you execute the query, but the first sublist is passed directly to the download interface and stored as a file. The first sublist must be a single-line basic list, a statistic, or a ranked list. When you select the field, a parameter is predefined on the selection screen.

Display as Table

When you select this option, your report output is displayed in an SAP Table Control object that looks similar to the SAP List Viewer but offers less functionality. The first sublist must be a one-line basic list, a statistic, or a ranked list. When you select this option, a parameter is predefined on the selection screen.

Word Processing

When you select this option, the word processing functions can be called from the list display and from the table display. You can use this option to create Microsoft Word form letters.

Spreadsheet

When you select this option, the spreadsheet functions can be called from the list display and from the table display. You can use this option to create Microsoft Excel spreadsheets.

Private File

When you select this option, the list is not displayed onscreen when you execute the query, but the sublist is passed directly to a function module. This is an SAP enhancement and must be implemented by the customer.


Copying Existing SAP Queries (Same Client, Same Query Group)

Follow these steps to copy a query:

1.

Navigate to the main screen of the SAP Query tool by using transaction code SQ01 and select from the list the query you want to copy (or type the query's name in the Query box at the top of the screen).

2.

Click the white copy button on the Application toolbar. The Copy a Query dialog box appears.

3.

Type in a new name for your copied SAP query in the To Query Name box and then press Enter. Be sure to follow the naming rules discussed earlier in this appendix when naming the copied query.

4.

When your copied SAP query appears in the same user group as the original, change the long report title (description) of the copied query to distinguish it from the original.

Copying Or Moving Existing Sap Queries (Same Client, Different Query Group)

Follow these steps to copy a query to a new query group:

1.

Navigate to the main screen of the SAP Query tool by using transaction code SQ01 and select from the list the query you want to copy (or type the query's name in the Query box at the top of the screen).

2.

On a scrap of paper, write down the name of the query and the name of the query group in which it currently resides.

3.

Press Shift+F7 to view a list of all query groups to which you are assigned.

4.

Double-click the query group you want to move the query to. You are now on the main screen of the SAP Query tool, and the query group is listed on the top left of the screen.

5.

Click the white Copy button on the Application toolbar.

6.

When a dialog box appears, take a look at your scrap of paper and type the query and query group names into the form.

7.

Type a new name for your copied SAP query in the To Query Name box, ensuring that the Query (User) Group lists the new query group name to which you are moving the query.

8.

Press Enter. Your copied SAP query, with its new name, appears in the new query group, along with the original query group.

9.

Be sure to change the long report title (description) of the copied query to distinguish it from the original (as needed), and be sure to follow the naming rules discussed earlier in this chapter when naming the copied query.

Deleting SAP Queries

To delete an SAP query, follow these steps:

1.

Navigate to the main screen of the SAP Query tool by using transaction code SQ01 and select from the list the query you want to delete (or type the query's name in the Query box at the top of the screen).

2.

Select the trash can Delete button on the Application toolbar.

3.

When the Delete Query dialog box appears, confirm that you want to delete the query by pressing Enter. A message appears in the bottom left of the screen, letting you know that the query has been successfully deleted.

Creating a Variant for an SAP Query

You can create a variant in several different ways. The following instructions work for any version of SAP, beginning with version 4.0:

1.

Begin at the main screen of the SAP Query tool, which you reach by using transaction code SQ01. Select the query for which you would like to create a variant by selecting (highlighting) the gray bar to the left of the table or by typing the query name in the box at the top of the screen.

2.

Select Goto, Maintain Variants. The screen ABAP Variants - Initial Screen appears.

3.

Type a name for your variant and then click the Create button. You are presented with the selection screen for the report for which you decided to create a variant in step 1. This screen gives you the opportunity to input selections that will be saved as a variant.

4.

Input values on the selection screen that you want to save and then click the Save button on the Application toolbar. The first time you save the variant, the Save Attributes screen appears. When you modify an existing variant, you can click the Variant Attributes button to access this screen.

5.

The only required field for entry on the Save Attributes screen is the Description field. Enter a description for your variant in this field and then click the Save button to complete the variant creation process. It is a good idea to use a description that describes the variant.

6.

Click the green Back button to return to the Maintain Variants screen.

7.

Click the green Back button again to return to the main SAP Query tool screen.

Executing A Report With A Variant (Execute With Variant)

Multiple variants can exist for a report, and you can decide which one to use prior to report execution by following these steps:

1.

Begin at the main screen of the SAP Query tool, which you reach by using transaction code SQ01. Select your report and then click the Execute with Variant button on the Application toolbar. A dialog box that contains a drop-down field of all the variants for the selected report appears.

2.

Select the variant you want to use and then press Enter.

3.

Click the Execute button. The report executes, displaying the saved variant.

Executing A Report With A Variant (Execute)

Multiple variants can exist for a report, and you can decide which one to use upon report execution by following these steps:

1.

Begin at the main screen of the SAP Query tool, which you reach by using transaction code SQ01. Select your report and then press F8 or click the Execute button. The report's selection screen appears.

2.

On the selection screen's Application toolbar, click the Get Variant button (immediately to the right of the Execute button). A dialog box containing a drop-down field of all variants for the selected report appears.

3.

Select the variant you want to use and then press Enter.

4.

Click the Execute button. The report executes, displaying the selected variant.

Saving An Sap Query With A Variant

In addition to selecting a variant prior to or upon report execution, you can save a variant with a query as a default, such that when the report is executed, that variant is automatically used to populate the report's selection screen:

1.

Begin at the main screen of the SAP Query tool, which you reach by using transaction code SQ01. Select your report and then click the Change button. The Title, Format screen of the SAP Query tool appears.

2.

In the Special Attributes section of the Title, Format screen, select the Variant drop-down box to see a list of all variants that exist for the selected report.

3.

Select the variant you want to use and then press Enter.

4.

Check the Execute Only with Variant check box.

5.

Click the Save button and then press F8 or click Execute.

6.

Click the Execute button. The report executes, displaying the saved variant. Because it was saved with the query, every time it is executed, the saved default variant will be used. The variant can be overwritten with new values, or a new variant can be selected after execution; however, it will always be presented as the default.

Editing A Variant For An Sap Query Directly From The Selection Screen

After a variant is created, you can modify it on the selection screen by following these steps:

1.

On the selection screen, change the values as desired and then click the Save button on the Application toolbar. A confirmation box appears, asking if you want to overwrite the existing variant.

2.

Click Yes. The changes to your variant are saved.

Editing A Variant For An Sap Query From The ABAP Variants - Initial Screen

After a variant is created, you can modify it on the screen ABAP Variants - Initial Screen by following these steps:

1.

Begin at the main screen of the SAP Query tool, which you reach by using transaction code SQ01. Select the query for which you would like to modify the variant by selecting (highlighting) the gray bar to the left of the table or by typing the query name in the box at the top of the screen.

2.

Select Goto, Maintain Variants. The screen ABAP Variants - Initial Screen appears.

3.

Select your variant from the drop-down box and then click the Change button. You are presented with the selection screen for the report.

4.

Modify the values on the selection screen as you like and then click the Save button on the Application toolbar.

5.

To modify the attributes, click the Variant Attributes button and make the desired changes.

6.

Make any other modifications desired on this screen and then click the Save button to complete the variant modification process.