Free cookie consent management tool by TermsFeed Blog - Eursap's SAP Tips: How to use dynamic variants in TVARVC table in ABAP development | Eursap
Upload SAP CV Upload SAP Job Hiring? Let's discuss Improve my CV Promote my CV

Eursap's SAP Tips: How to use dynamic variants in TVARVC table in ABAP development

Feb 03,2023 | Written by Jon Simmonds

Eursap's SAP Tips: How to use dynamic variants in TVARVC table in ABAP development.

Avoiding hard coding in programs can sometimes be difficult, but it is essential in order to maintain the integrity of your SAP system and avoid a maintenance headache going forward.

SAP has a standard solution to this conundrum – table TVARVC.

This table can be maintained using transaction STVARV.

See below for the transaction. It has the option to add single variables for using with a PARAMETER selection in an ABAP program/transaction, or the option to use SELECT-OPTIONS in an ABAP program/transaction.

Once you create and save your entries in transaction STVARV, the entries are written out to table TVARVC, as below.

As can be seen, the “Type” refers to “S” for SELECT-OPTIONS and “P” for “PARAMETERS” in your ABAP program.

For example, your ABAP statement to read a parameter could look something like:
SELECT SINGLE low
FROM TVARVC
INTO lv_variable
WHERE type = ‘P’ AND name = ‘variable name’.

This saves you from hard coding and means whenever a variable changes its value, you can amend using transaction STVARV instead of amending the ABAP program directly.

Looking for an SAP Job?
SAP Jobs
Looking to hire SAP Talent?
Hire Now