Using Variants


As mentioned throughout this chapter and Chapter 5, you can use a single SAP query report to satisfy multiple reporting needs simply by changing the values entered on the report's selection screen. To spare a user from having to enter the values each time a report is executed, you can save entries on a selection screen as a variant. A report can have an unlimited number of variants associated with it.

As discussed in Chapter 5, which introduces the concept of selection screens, one basic report (for example, a list of all associates at Mama Tricarico's Restaurant) can be run with three different variations on the selection screen to produce three different reports. The following sections describe how to make a saved version of a selection screen for an SAP query report.

How to Create 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. (The example used here uses a test HCM query. To follow along, you can use an existing query of your own from any application module.)

2.

Select Goto, Maintain Variants. The screen ABAP Variants - Initial Screen, shown in Figure 6.6, appears.

Figure 6.6. You use the screen ABAP Variants - Initial Screen to create variants for SAP queries.


3.

Type a name for your variant (for example, DLS_Variant01, where you replace DLS with your initials) 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 (see Figure 6.7).



Figure 6.7. This selection screen lets you input selections that will be saved as a variant.


4.

Input values on the selection screen that you want to save. Which specific values you input for the example are unimportant, but for the sake of this example, input the Period field as of today and enter the value 1 in the Employee Group field. After inputting any values you want to save, click the Save button on the Application toolbar. The first time you save the variant, the Save Attributes screen, shown in Figure 6.8, appears. When you modify an existing variant, you can click the Variant Attributes button to access this screen.

Figure 6.8. The Save Attributes screen looks the same for all reporting variants.


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 (refer to Figure 6.8).

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.

To see that the variant you created is now available for the report, you need to execute the report that has the variant, as described in the following section.

Executing a Report with a Variant (Execute with Variant)

Upon report execution, you can select a variant for use in your report. By using variants, you can use a single report for multiple things, based on the information entered on the selection screen. 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)

You call also select the variant of your choice from a report's selection screen. 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 SAP Query (Directly on 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 SAP Query (on the Maintain Variants Screen)

After a variant is created, you can modify it on the Maintain Variants 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.

Advanced Functions for Variants

To see what options are available on the Variant Attributes screen, follow 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.

Click the Variant Attributes button to view the available options on the Save Attributes screen (refer to Figure 6.8).

The Save Attributes screen has dozens of available options. Table 6.1 describes the general options available.

Table 6.1. General Functions Available on the Save Attributes Screen

Option

Description

Variant Name

This field contains the name of the variant that is input on the Maintain Variants screen during the creation process.

Description

This field contains the required description field that users must populate with a description of the variant.

Created for Selection Screens

This field displays the number of the R/3 dynpro (screen) that is displayed at runtime. It may also be recorded in trace or logging information.

Only for Background Processing

If you select this check box, the variant can be executed only in the background. If you do not select it, it can be run both in the background and online.

Protect Variant

If you select this check box, the variant can only be changed by the person who created it or who last changed it.

Only Display in Catalog

If you select this check box, the variant name appears in the directory but not in the general input help.

System Variant (Automatic Transport)

This system variant is transported automatically.


The Field Attribute options listed in Table 6.2 can be indicated for any of the fields by placing a check mark in the bog next to each.

Table 6.2. Field Attributes Available on the Save Attributes Screen

Option

Description

Required Field

This attribute indicates that the designated field requires entry on the selection screen prior to report execution.

Switch GPA Off

The field contents are ignored when the variant is imported.

Save Field Without Values

If you select this field, the value of the corresponding field on the selection screen is not affected when you start the program by using a variant.

Selection Variable

If you select this field, the field on the selection screen is assigned a value from a variant variable.

Hide Field 'BIS'

If you are using BIS, if you select this option, the corresponding field is not displayed when the user starts the program using this variant. However, you can still assign a value to the field in the variant.

Hide Field

If you select this option, the corresponding field is not displayed when the user starts the program using this variant. However, you can still assign a value to the field in the variant.

Protect Field

If you select this option, the user cannot overwrite the value in the field on the selection screen.


Note that the bottom section of the Save Attributes screen lists every field available on the selection screen. Each is classified with a type. The field type indicates whether the field is a parameter (P) or selection option (S).

Helpful Hint

The selection screens designated for the program are displayed one after the other. Because a parameter or selection option can occur on more than one screen, the attribute fields for that field accept input only the first time they appear.





SAP Query Reporting
SAP Query Reporting
ISBN: 0672329026
EAN: 2147483647
Year: 2006
Pages: 161

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net