GRC
HR
SCM
CRM
BI


Blog

 

Variant creation for reports

by Rithin Shah

November 16, 2012

Creation of Variants for reports

Introduction:

If you want to run a report programs with same selections at regular intervals (for example, for monthly sales statistics) you would not want to enter the same values each time. Some ABAP/4 offers the possibility to combine the desired values for all these selections in one selection set. You can create as many different selection sets as you like for each report program and they remain assigned only to the report program in question. Such a selection set is called a variant

Using variant in background processing, starting a report via variant saves the user work, minimizes in out errors. In background processing, a variant is the only possibility you have to pass values for the selections

SAP users need to execute reports during their normal course of business. Users need to enter different selection criteria to access the dataset they need. Users need not enter the report selection criteria each time they need to access a report. Here, SAP provides users with the functionality of report variants.

 

Creating Report Variants                                                                                                  

Use of Variants in Selection Screens:

While executing most of the display or edit transactions and while running any kind of report, selection data needs to be provided to SAP on the selection screen. Many times the same report needs to be run repeatedly with the same selection parameters. This is where the use of variants saves the end user from entering the same selection data again and again every time the report needs to be run.

Instead, the selection data is entered once and then stored as a variant. Next time whenever the same report needs to be executed with the same selection data, the variant is simply selected and it automatically populates all the selection fields.

Use of variants not only saves the time and effort for the end user but also ensures that the correct reports are executed and errors due to manual entry of the selection parameters can be avoided.

The SAP best business practices suggest that the selection data for frequently used reports should be saved as protected variants. Protected variants can be used by any user but can be modified only by the user who created the variant. This allows multiple users to execute the same report and ensures the consistency in the output of the report.

Variants also remove the dependency on a certain user for running a certain report. A complete knowledge about the report and the underlying module is required for entering the selection data for a report. Only a person from the HR department can understand the selection data for a personnel report. But if the selection data is saved as a variant, then anyone having basic knowledge of SAP can run the report.

Instead of entering the same values in selection criteria input fields each time you execute a report, you can create a variant. Using variants reduces both data entry time and system processing time.

Pre-requisites:

You must have the proper authorization to create a variant. See your system administrator for information on authorizations.

A report can have any number of variants attached to it.

 

Procedure:

Go to transaction SE38 enter the program name and click on icon Variants so that variants could be created.

  1. On the initial screen of the ABAP Editor, enter the name of the program for which you want to create a variant, select Variants in the Sub-objects group box, and choose Change.
  2. On the variant maintenance initial screen, enter the name of the variant you want to create.
    Note the naming convention for variants
  3. In the Variant input field, enter a name for this variant, and then click on Create. You can use any combination of characters to create the variant name except for special characters, such as the percent sign ("%") and dollar sign ("$").
  4. Choose Create.
    If the program has more than one selection screen, a dialog box appears in which you can assign the variant to one or more screens. The dialog box does not appear if the program only has one selection screen. In this case, the selection screen of the program appears straight away.
  5. If there is more than one selection screen, select the screens for which you want to create the variant.
  6. The selection criteria screen for the report is displayed.
  7. Enter values in the selection criteria input fields.
  8. For information on how to enter or change values, see Entering Selection Criteria in a Report.
  9. Click on Continue.
  10. The Save variant screen is displayed. The name you entered for the variant is displayed in the Variant field.
  11. In the Description field, enter a short description of the variant.
  12. Select any of the following environment options by clicking on the check box to the left of the option. Your choices will affect the variant as a whole.

Only   for background processing

Mark this field if you need your variant only for background   jobs and not for online (Dialog) processing. You should always print large   lists in the background.

Protect   variant

 Mark this field if you   want to prevent other users changing your variant. In such a case you will be   the only person who can

Only   display in catalog

Mark this field if you want to call your variant only in   variant catalog and not via search help (F4)

System   variant (automatic transport)

This field would be automatically flagged when you create a   system variant (CUS&, SAP&)

Definition for Objects of selection screen: Select any of the following characteristics for the individual selection criteria by marking the corresponding check box:

ü  Type: This field is used as an indicator to specify whether a specific field is a Parameter (P) or a selection (S). You will have to use "Type" when creating variables via table TVARVC

 

ü  Protect field: Mark this field is you want to set it to “Read Only” in the selection screen. Field will be visible in the selection screen with content you have saved, but cannot be edited.

 

ü  Hide field: Mark this field in case if you want to hide it in the selection screen. Data you have entered in this field will be used for processing, but not be visible in the selection screen.

 

ü  Hide field "BIS": Mark this field, if you want to hide the range selection option.

 

ü  Save field without values: If you mark this field, then the system will ignore the values which you have saved in the variant once it is imported to selection screen.

 

ü  Switch GPA: This field is used for the purpose of filling values from the memory ID of the user. This is not active for background processing.

 

ü  Required field: Mark this field if you want to set a mandatory flag in the selection screen. For example, if you mark the field in the variant, then in the selection screen this field would become a mandatory field. 

  1. Save the variant by clicking on save or pressing CTRL+S

Result:

When you have finished, an overview screen appears (ABAP: Save Attributes of Variant), on which you can enter the attributes of your variant and save it.

Note that when you create a new variant, you must enter both values and attributes.

Names of variants: Names can consist of up to 14 alphanumeric characters. The "%” character is not allowed. If you want the variant to be transported automatically with its program, you must create a system variant. The name of a system variant starts "CUS&" for customers, and "SAP&" for SAP system variants. You can only use the "&" character within this prefix in the name of a system variant. It may not occur in any other context. System variants are administered by the Workbench Organizer. Alth ough you can create and access variants from any client, they are always stored in client "000".

The variant is saved and its values are displayed on the selection criteria screen.

Creating a transport request:

After creating the variant, go to SE38 ABAP editor screen à enter program name à select Variant from the sub objectsà click on Changeà Enter newly created variant name à Go to UtilitiesàTransport request.

Here we can enter the Program name & Variant name and Execute. Choose the variant you want to transport and click on Continue. It will prompt for a workbench request. The transport request is created which is a client dependant object.

Table where variants are stored:

How to find the report and variant from table:

All variants are stored in the table – VARID

Get the required information in the combination of Report name and variant name.

You can use the function module –“RS_VARIANT_CONTENTS” to get the values of your variant.

Schedule background job:

1. Online

 Go to SE38àEnter program nameàExecute in Backgroundà Enter output device à Select Start time as Immediateà Save

You can check the report execution status from SM37 or from the same screen choose Systemà Servicesà Jobsà Jobs overview and click on Execute. The screen would show the Jobs overview list.

 

2. Schedule

Scheduling Background Jobs:

Find below steps in defining background job:

1. Background jobs are scheduled by Basis administrators using transaction SM36

2. To run a report in a background, a job needs to be created with a step using the report name and a variant for selection parameters. It is recommended to create a separate variant for each scheduled job to produce results for specific dates (e.g. previous month) or organizational units (e.g. company codes)

3. If spool requests generated by this job are to be sent to someone as email, specify the email address. Choose the Spool list recipient button.

4. Click on start condition in application tool bar

5. In the pop-up window, click on Date/Time

6. Below you can see a check box "Periodic Job"

7. Next click on Period Values

8. Select "Other Period" – Enter the values are per the requirement

9. Save the job.

In order to view the job newly scheduled, go through transaction SM37. Here mention the job name or the report name to check the status of the job.

After mentioning the job name or program; execute it. (If you execute without any name then it gives populate all the jobs set by your user name.

Select the Job status as Scheduled, Released, Active, Finished etc.

Thus we have seen what is a variant, how to create variant, transport it to various clients and scheduling of background jobs.

========================================================================================

References: www.learnsaptips.com

                  Source: help.sap.com

Did you find this blog helpful? Get access to the latest updates and resources from SAPinsider with a free subscription.

Get the SAPinsider subscription now »»

An email has been sent to:






More from SAPinsider



COMMENTS

Please log in to post a comment.

No comments have been submitted on this article. Be the first to comment!


SAPinsider
FAQ