In SAP ABAP reports have a mechanism for entering values for database selection or for performing different calculations through SELECTION SCREENS.
Selection screen provides a user an option to execute the reports or transactions as per his requirements and thus provide a range of values as an input.
Whenever there is a requirement to execute a report with the same set of input values again and again, for large selection screens entering the same values can be a tiresome and boring task. Thus SAP has provided a functionality to save these values in a set called as VARIANTS.
In order to save a variant just key in the values on selection screen and click on save button.
Variants can prove to be useful in various ways:
As mentioned above, when there is a requirement to execute a report with a same set of values every time.
When a report needs to be executed in background mode, variants are the only way to pass values to the report.
Variants can ensure the integrity of the data being passed as an input and thus minimize the risk of incorrect data entry.
TYPES OF VARIANTS:
Variants values can be Static or Dynamic.
STATIC: Static values are fixed values and do not change over the course of time.
Example: Let us suppose there is an organization with 10,000 employees and the HR executes a monthly report having the personnel number as input ,each month. Then in this case we can use the static value giving the range as 1 to 10,000 for this.
DYNAMIC: Dynamic values in a variant can change over time.
Example: The HR wants to execute the report daily and gives the current date as the input. The requirement is that next day when the report is executed the date should be changed to current date.
In such case we can use dynamic values. If the dynamic value is a date , we can use the different date calculation options provided by SAP.
In other cases we can use the values stored in table TVARVC.
PROTECTION OF VARIANTS:
Variants can be saved as protected variants so that only the creator has the authority to change the variant at a later point of time. This can be done by selecting the checkbox for variant protection at the time time of saving variant attributes.
Variants are client dependent.
VARIANT VALUES: The variant values are stored in a table named VARI.
VARIANT DIRECTORY: The table VARID is a directory of variants present in system.
This table stores values such as : Variant Name , Report name for which variant is created , Information about when and by whom the variant was created ,version of variant , protected , transport and environment information.
Protected: This tells whether the variant is protected or not.If a variant is a protected variant then it can be modified only by the user who has created it.
Transport: This gives the information whether a variant can be transported to other systems or not.
Environment: Gives information about the variants usage in foreground or only in background processing.
How to change protected variants? : To change protected variants we need to remove the protected flag from VARID table for a given variant. SAP has provided a standard program for this purpose.
Program : RSVARENT can be used to unprotect the variants. It takes report and variant name as input. This report is used to cancel variant protection.
Next Blog: The next blog focuses on variant attributes and their usage.