Dynamic date manipulation for Variant in SAP ABAP

Author | Last Updated| | 5 Comments | F Share

Dynamic date manipulation in variants in SAP ABAP, update variant date dynamically in SAP ABAP variants

+ -

Step1:Creating Variants for SAP ABAP programs Normal Top^

Variant is a concept of saving a set of input fields with values with a particular name, so that we can use the same set of inputs next time, the below is the example of creating variants in SAP ABAP programs.

Create a program with a selection-screen.

REPORT ZSAPN_DYNAMICDATE.
DATA LV_DATUM TYPE DATUM.
PARAMETERS P_DATE TYPE DATUM.
SELECT-OPTIONS S_DATE FOR LV_DATUM.

Creating variants in SAP ABAP reports

Provide some input values, click on save button.

Creating variants in SAP ABAP reports

Provide variant name, description and save.

Creating variants in SAP ABAP reports

How to use variant in SAP ABAP programs

Go to the program selection screen, you will find variant icon, click on variant icon.

Creating variants in SAP ABAP reports

You will find list of variants available for the program, double click on any variant, the values will be populated to screen automatically.

Creating variants in SAP ABAP reports

Creating variants in SAP ABAP reports

Step2:Dynamic date in variant for parameters Normal Top^

Go to report selection screen.

Provide some input values, click on save button.

Dynamic date in variants in SAP ABAP

Press F4 on selection variable input of parameter date,select D:Dynamic Date Calculation, enter.

Dynamic date in variants in SAP ABAP

Press enter, press F4 on name of variable, double click on  current date +/- ??? days.

Dynamic date in variants in SAP ABAP

A pop up will open enter -1, means current date -1..(todays date -1, changes dynamically everyday).

Dynamic date in variants in SAP ABAP

Save the variant, go to report selection-screen select variant by clicking on variant, you will find yesterdays date on selection screen, this will changes dynamically every day.

Tutorial Comments

Total Comments: Add your Comment
17 Feb 2014

Nice to see more information about variant.. actually we do date calculation in initialization event.

07 May 2014

This is new for me. Thanks for sharing.

27 Dec 2015

i want know how to use variant in background session ? please if you know email me ? thank you.

23 Apr 2017

Nice topics. Please it will be better some scenarios

05 Jun 2017

Thank you very much.........................................................

Leave a Comment

Enter Comment Text