How to Create a Dynamic Variant in SAP using TVARV Table

H

In this blog post let us take a look at how we can create a dynamic variant in SAP ABAP program using TVARV table. To demonstrate this I have created a sample custom program “ZTEST” with one select option “S_TEST” on which we are going to create a dynamic variant. The value for the select option “S_TEST” will be dynamically picked from corresponding entries in TVARV table.

The Output of Selection Screen looks like below screenshot, Now we are going to create a dynamic variant for the below selection screen.

Step 1: Maintain the dynamic entries in table TVARV. This can be done using transaction “STVARV”. ( Please be aware that transaction is not “STVARVC” ) Later we have to assign this newly created variable with dynamic variant field. I have created a new entry under Selection Options tab of the transaction “STVARV” with name “ZMATNR” as shown in the screenshot. The titles “Lower limit” and “Upper Limit” indicate the minimum and maximum range of the given selection option.

Now let us create a dynamic variant for the selection-screen. This is done through normal way of creating variant by just clicking “Save” button on the selection screen (Ctrl + S). As soon as you press “Save” following screen will be displayed, Where I have entered “Variant Name” and “Description”.

To  use the table field as value in the select option we have to chose table “Selection Variable Type” as “T” which indicates “Table Variable from TVARVC”.

Then Assign the Variable that you have created using the “STVARV” transaction in the field “Name of Variable” as shown in the below screenshot.

Now we can save the variant with the  details we just have entered and the following screenshot highlights the important fields in the variant.

Select the variant from Variant catalog. It will populate “S_TEST” select-option with the values maintained in TVARV Table against variable “ZMATNR”.

If you found any issues in following the post or for any other queries please comment below.

About the author

Add comment

By Pavan

Recent Posts

Recent Comments

Archives