Eursap’s Tip of the Week: Using selection variables when saving a report variant
Saving a variant of a report in SAP is a vital component to personalising your SAP experience. However, what do you do when you want the selection parameters in the report to be dynamically determined, like a date for example?
To do this, you can use the Selection Variable field when you save the variant. Follow the below steps (I am using the standard transaction VA05, or Fiori app “List Sales Orders” for this example):
1. Once you have named your variant (without spaces) in the Variant Name field and added a description, you need to add the selection parameters. The Selection variable field can be seen, as below.
2. Once in the correct field, click on the drop-down icon in the field, or press F4 on your keyboard. This will bring up the options, as below.
There are three options here:
• T – Table Variable from TVARVC – this is often used when running the transaction from within a program. There is a standard SAP table called TVARVC which can hold variables which can be read from these programs. This is a useful way of running these transactions without having to “hard code” values into your selections (i.e., the values can be changed in the TVARVC tables rather than direct in the transaction).
• D – Dynamic Date Calculation (Local Date) – this is a selection which will read the time and date assigned to your local user and calculate the values based upon that.
• X – Dynamic Date Calculation (System Date) – this is a selection which will read the time and date assigned to the SAP system and calculate the values based upon that.
All three options work in conjunction with the next field on screen – Name of Variable.
In practice, you are more likely to select D or X than T.
3. Once your selection variable has been selected, you will need to drop down the list of options from the Name of Variable field and select an appropriate entry.
4. From here, we can choose how the system calculates the date in that field when your variant has been run. For example, if we select “Current Date”, then the current date can be selected. This can be done by double clicking the option. Additionally, by using the “Indicator” and “Option” columns, further options are available – for example, the current date can be excluded, or all dates can be read EXCEPT the current date, etc.
5. Furthermore, there are other options available here, which can be seen by the presence of question marks. If you double click one of these options, then further input is required.
In this selection can be added the number of days before or after the current date. To select a number of days before, use the minus sign. For those entries where we have xxx and yyy as variables, you can enter a range of dates in the same format.
6. Once you have created these entries, save your variant as normal and the report will automatically and dynamically calculate your date requirements every time the report is run using that variant. This functionality is available in the SAP GUI as well as in standard SAP transactional Fiori apps, as can be seen below:
I hope you find this useful! Stay tuned for another SAP Tip from Eursap next week.
Be sure to also check out Eursap’s SAP Blog for more in depth articles.