100% found this document useful (13 votes)
34K views25 pages

Variant Maintenance in SAP

Selection variant is a very commonly used feature in SAP to save set of input values for a selection screen of a program. You can execute the program easily by calling the relevant variant. Selected variant will contain all necessary values for your selection criteria. For example, if you run a report in SAP, you will first get a selection screen, where you need to maintain the selection criteria to filter data out of SAP. If you have to fill same set of data every time you execute this report, then you can save those values as a variant. And also similar setup is significantly used in large scale SAP customer to execute AFS allocation run, delivery note creation, etc in the background mode. These variants can be used both dialog mode (Online) and background execution.

Uploaded by

Anupa Wijesinghe
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
100% found this document useful (13 votes)
34K views25 pages

Variant Maintenance in SAP

Selection variant is a very commonly used feature in SAP to save set of input values for a selection screen of a program. You can execute the program easily by calling the relevant variant. Selected variant will contain all necessary values for your selection criteria. For example, if you run a report in SAP, you will first get a selection screen, where you need to maintain the selection criteria to filter data out of SAP. If you have to fill same set of data every time you execute this report, then you can save those values as a variant. And also similar setup is significantly used in large scale SAP customer to execute AFS allocation run, delivery note creation, etc in the background mode. These variants can be used both dialog mode (Online) and background execution.

Uploaded by

Anupa Wijesinghe
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
You are on page 1/ 25

Contents

Introduction .................................................................................................................................................. 2
How to create a variant ................................................................................................................................ 2
Using Selection Variable ......................................................................................................................... 10
Using D- Dynamic date calculation option ...................................................................................... 11
Using T Table variable from TVARVC option ................................................................................. 14
How to call a variant ............................................................................................................................... 19
How to change a variant ......................................................................................................................... 20
Option 1: Via save variant option ....................................................................................................... 20
Option 2: Via table TVARVC ............................................................................................................. 20
Option 3: Via transaction SE38 - Variant option ................................................................................. 20
Table where variants are stored ................................................................................................................. 24



Introduction
Variant is a very commonly used feature in SAP to save set of input values for a selection screen of a
program. You can execute the program easily by calling the relevant variant. Selected variant will
contain all necessary values for your selection criteria.
For example, if you run a report in SAP, you will first get a selection screen, where you need to maintain
the selection criteria to filter data out of SAP. If you have to fill same set of data every time you execute
this report, then you can save those values as a variant.
And also similar setup is significantly used in large scale SAP customer to execute AFS allocation run,
delivery note creation, etc in the background mode.
These variants can be used both dialog mode (Online) and background execution.
How to create a variant
In most of the executable programs you have an option of saving a selection variant. For example I will
use transaction VL06G (Program - WS_MONITOR_OUTB_DEL_GDSI) to demonstrate the variant creation
option.
Call the necessary transaction else call the relevant program name in the transaction SE38
Fill all required fields
Click on the save button

Now you will jump to a Variant Attributes screen. You have below fields available in this
screen
Description - Enter a name and description for your variant. You can use prefix CUS& or
SAP& for system variants.

Only for Background Processing Mark this field if you need your variant only for
background jobs and not for online (Dialog) processing

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 change this variant.

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

System Variant This field will be automatically flagged when you create a system variant
(CUS& or SAP&)

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 if 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 the 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

For example, if I save my variant without a flag in this field for field Shipping Point,

And run the transaction with my variant, then the selection screen would be;

Now if I flag the same field in my variant as shown below,

And run the transaction with my variant, then the selection will change to;

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

For example, before save my variant, I maintain A300 as my shipping point. The flag was not set in the
variant. Just for identification purpose I will also mark the Protect field as well. See below for my
variant;

Now when I execute the transaction with this variant, my selection would be;

Now I will change my variant with the flag in the field Save field without values. Therefore now my
variant is;

Now when I call the transaction with this variant, my selection screen will change to;

As per the definition system has ignored the values I saved in my variant.
Switch GPA off 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 I mark this field in my variant as shown below;

In the output screen, Shipping point will become a mandatory field

This feature is very commonly used to avoid user error.
Using Selection Variable
Selection Variable / option / Name of the Variable These fields are used to specify
variable values in the variant.

This is a very handy tool introduced to variants specifically to propose dynamic dates in the variant. This
feature is used to run AFS allocation run, delivery note creation in background mode.
Using D- Dynamic date calculation option
Lets say you want to run this program in background mode and the selection date Planned Goods
movement date should be set to todays date (System date). In other words, every day when the
background job starts running with the variant, this date field should be automatically set to System
date. This can be easily achieved using variable option.
What you need to do;
Go to the line which contains your respective date field
Under column Selection variable set D Dynamic date calculation flag

Under column Name of the variable select the value Current Date

Note:
You have below options available under this field;

Save the variant.
Now when you call this variant again anytime, system will automatically set the system date
in to this field.
Eg:

Now lets say you want to consider 5 days from the system date. In such a case, you can set the
variant as below;

Save the variant.
If I run this variant on 29/08/2012, my selection will be automatically set as shown below;

The date was calculated automatically based on the variable values in the variant.
Using T Table variable from TVARVC option
This option is most commonly used for background processing. With this option, you dont have to
create a new variant or change the existing variant every time when you need to do a minor change in
your variant. You can simply change the values stored in the table TVARVC.
Table TVARVC as below fields;

You can maintain entries in this table via transaction STVARV.
Call the transaction STVARV
Since we need to add selection variable, go to the tab (This is same as P
or S which you saw under Type field in the Variant Attributes tab)
If youre in display mode, change it to edit mode using button

To add a new entry in to this table, click on the button
Give a name to your variable under field Name

If you have to range to specify for your field, you can do it under Lower Limit and Upper
Limit columns
Since I am planning to use this variable for my shipping points, I will maintain it under Multiple
Values option. To do that, click on the button

Maintain relevant values

Save the variable using button

Now go back to the transaction and maintain the data you want and press the in the selection
screen to call the save variant option

For the field Shipping Point under column Selection variable select option T

Now press F4 under the field Name of the Variable to select the newly created variable with
shipping points

Finally my variant looks like below;

Save the variant using button
Now lets run the transaction with my variant
As you see, now shipping point field is filled with values out of the variable ZAW1 which I
created in the table TVARVC


How to call a variant
In the online mode you can use button in the selection screen to see all variants save for
the transaction


How to change a variant
You have 3 options to change an existing variant.
Option 1: Via save variant option
Call the transaction with the variant you need to change
Maintain new values for your variant and press the save button
From the Variant Attributes screen press the save button again
Select option YES to override values of your old variant


Option 2: Via table TVARVC
If you have any variables maintained in the table TVARVC and you need to change them, call the
transaction STVARV
Change the variable value according to your new requirement
Save the variable
When you call the variant in the next time, system will include all changes out of that variable in to
selection screen
Option 3: Via transaction SE38 - Variant option
For this you need to know the relevant program name of you transaction.
Call the transaction SE38.
Enter your program name and mark the field and click on the button Change

Press F4 under field Variant to select your variant

If you want to change any value of you variant, click the option Values and press the button
Change

You will jump to the selection screen to change values

If you want to change any attribute of the variant, select the field Attributes and press the
button Change

You will jump to the Attributes screen


Table where variants are stored
All variant are stored in the table VARID
It contains below fields

If I execute this table for my variant, I get below data set

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

Author: Anupa Wijesinghe
E-Mail: [email protected] / [email protected]
Website: www.learnsaptips.com
View my profile in LinkedIn
Follow me on Twitter


Disclaimer

This article is done based on my research and readings, unless otherwise stated. The views expressed
are my own and not of anyone else.
Author accepts no liability for the content of the articles in this website or for the consequences of any
actions taken on the basis of the information provided. Using this information is at the users own
discretion and responsibility.

You might also like