SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software Kodyaz SAP and ABAP Programming Tutorials
Development resources, articles, tutorials, samples, codes and tools for .Net, SQL Server, Vista, etc.




Win FREE BOOK
from Kodyaz



CRM Companies List
Web Based CRM Software

Create SAP Dynamic Variant using Date Calculation

SAP dynamic variant creation is a must for more flexible ABAP reports that are more user-friendly. For example if SAP users are using an SAP program which displays current date's orders, in order to prevent them to choose the today's date from select screen everytime they execute the report. ABAP developers can create dynamic variant in SAP for that report, so that the date select option will always display today's date (current date)

Actually a dynamic variant uses a variable and a calculation formula to set the value of the selection option variable on the screen every time the report is called.

In this ABAP tutorial, I'll try to define dynamic variable for date selection-option so that it will always display 6 months earlier than today.





Call SAP transaction SE38 just as you will run the target ABAP report.
Type the ABAP report name into the Program textbox in SAP SE38 transaction screen.
Do NOT press Enter or F8 function key. Instead on the top menu where icons and buttons are listed, you will see Variants button. Press Variants button in order to create dynamic variant for your ABAP program or to modify an existing variant.

display SAP variant for ABAP program

When you pressed Variants, the next screen will let you select the SAP variant for the ABAP report that you will configure as a dynamic variant. This screen is named as "ABAP Variants - Initial Screen" as you see in below screenshot.
You can select the possible SAP variants defined for the related SAP program by pressing the F4 for the value help screen. Or you can just type a name for your dynamic SAP variant, and press the Create button next to the Variant textbox.

I will change the SAP variant named ZTF0_Yearly and define a dynamic date for the ABAP select options. So after selecting the variant name, I selected "Value" select option and then pressed Change button to make the changes

choose variant name for ABAP report

ABAP developers are now ready to configure SAP variant select option values using the below screen. I want to configure the date field so that it will be dynamically calculated and displayed every time the ABAP report screen is called with this SAP variant. The date select option is set to a static value currently. We will change it with a dynamic calculation.

Before continue with the next step, you can provide static values that are needed for selection options

maintain variant for ABAP report

In order to modify the SAP screen select option for date field, click on the date select option on the screen.

choose selection field for dynamic variant

After the related select option field is selected by placing the cursor onto that field, press the Variant Attributes button which is on the top icons and buttons menu

SAP variant attributes button

The SAP variant configuration screen is displayed. You will see a long list of parameters and select option attributes that can be configured by just marking the checkboxes for that variant. It is also possible to define a dynamic variant calculation rule on this screen. I'll now show ABAP developers how to set the value of the date select-option field dynamically to 6 months before than the current date.

The date select option field is S_ERDAT. By configuring the Selection variable column properties, ABAP developers can create a dynamic variant for their ABAP reports.

Just click on the Selection variable column and from value help screen choose "D" as type of variable which means D: Dynamic date calculation.

I'll not continue with this ABAP tutorial with the T, variable type which means T: Table Variable from TVARVC. This is a topic of an other ABAP tutorial.

Dynamic date calculation for variant

ABAP developers can use the following Dynamic Date Calculation formulations in order to create SAP dynamic variant variables.

Dynamic Date Calculation formulations:

Current Date: Always displays the current date when the screen is called
From month start to today: Defines a range of dates between the first of month to today

Current date +/- ??? days: Calculates a date by adding or substracting a predefined amount of days. I'll use this option to set a dynamic date which is 180 days before today. That is nearly 6 months before today.

Current date +/- ??? work days: Calculate a second date by adding (or substracting) a fix amount of working days from current date
First day of current month: Displays the first day of current month
nth working day of current month: Displays the Nth working day of current month
First day of next month: Displays the first day of the next month
First day of previous month: Displays the first day of the previous month
Last day of previous month: Displays the last day of the previous month
Last Day of the Current Month: Displays the last day of the current month
First quarter ????: Displays the first quarter as a date range
Second quarter ????: Displays the second quarter as a date range
Third quarter ????: Displays the third quarter as a date range
Fourth quarter ????: Displays the fourth quarter as a date range
Current date - xxx,current date + yyy: Displays date range calculated between by substracting xxx days from today and adding yyy days to current date
Date - xxx, Date + yyy (work days): Makes the same formulation as above calculation but this time using work days
Previous month: Shows the previous month as a date range period
Current period: Shows the current month as a date range period
(Beginning of mth-xx months, end of mth+yy months):

You can see the dynamic variant configuration for the S_ERDAT select field on the below screen. The Sign is selected as I (inclusive) among I/E. E stands for exclusive.
The Option is "<=" which is for "Less than or Equal to"
And for the parametric number of days, I provided the 180 days which is approximately 6 months.

dynamic variant date calculation configuration

This is after the dynamic variant configuration is completed for date select option field in your SAP program select-options screen

dynamic date variant calculation for 6 months

I hope to answer the question "how to create dynamic variant in SAP selection screen" for date fields using a date calculation formula in this SAP tutorial.







SAP Tutorials

SAP Tutorial

SAP Forums

SAP Tools

SAP Transaction Codes Table






Recent and Top SAP Tutorial and ABAP Tutorials

Read Pricing Condition Text using ABAP in SAP Sales Document Output
Export SAP Data to Fixed Length Text File
Save Table Contents into Text File and Download File
Business Document Service Error: Error when accessing graphic (BDS), RC = 5
Get Proforma Invoice from Commercial Invoice in ABAP
Convert Sales Unit into Text using Function Module in Target Language
Get Fullname of SAP user using Function Module in ABAP Program
ABAP Submit Report to Run Another ABAP Program within Code
Message no XS826: Cannot process message; no node determined for 76550052
SE63 Smartform Translation and Export using SLXT Program
VF31 SAP Transaction to Reprocess Billing Output Messages
Import and Export SO10 Standard Text using RSTXSCRP ABAP Program
CALL_FUNCTION_NOT_FOUND ABAP Run Time Error
SAP Output Management - Create New SAP Output Type
SAP Purchase Order Tables, Transaction Codes and Output
Assign SAP Item Category to Sales Document Type using SPRO
Window MAIN does not fit onto page PAGE (height)
SAP Invoice Output ZZZZ is not Defined
Invoice Output fail because of missing Billing Type text in TVFKT table
Read Integer and Decimals of a Numeric Value in ABAP Programming
SAP Smartforms Table Parameter in Form Routine
Complex Conditions in SAP Smartform with AND/OR
Free Adobe LiveCycle Designer Download
Create SAP Dynamic Variant using Date Calculation
Translate Web Dynpro Header Title displayed on Web Browser
ABAP RegEx for ABAP Regular Expression to fetch Date from String
Change Output Condition Records
Web Dynpro Text Translation using Assistance Class
Move Minus Sign from Right to Left of Negative Number in SAP Smartform
Read Address Data using FM ADDR_GET instead of Querying ADRC Table
Add Value Help to Web Dynpro Select Options
Add Web Dynpro Applications to SAP Favorites Menu
Component Usage ALV Does Not Have an Active Component
Web Dynpro Component Service Syntax Error in Program /1BCWDY/O3EC1AX6A3OVKK9L5FXO==CP
Web DynPro Tutorial - Display Spool Requests using Web DynPro Table
Web DynPro Tutorial - How to create Web Dynpro Application (Web Dynpro Component)
Display Data on Web DynPro Table Element
Test Web Dynpro ABAP Component by Creating Web Dynpro Application
Insert SAP Icons and Symbols on Smartform Documents
How to Display Text on Sap Smart Forms
Graphics White Background Displayed Grey on SAP Smartform Output
Get SAP Document Flow using SD_DOCUMENT_FLOW_GET ABAP Function Module
Convert Numeric Value or Currency into String Spell_Amount Function Module
How to Transport SAP Graphics using SE78 Transaction
How to Delete Standard Text using SO10 SAP Transaction
Dynamic Programming using Field Symbols in ABAP Reports
How to Disable Word Editor in SAP Smartform Text
How to Debug Popup Screen in ABAP
TVAP Item Category and SAP Table TVAPT for Text Translations
ABAP Runtime Error ST22 Transaction using Short Dump Analysis
Create Transport Request for Text Translations using RS_LXE_RECORD_TORDER
SAP Invoice Output Determination Analysis for Not Created Output Message
Set Default Single Values List for SAP Selection Screen Parameter
SAP Payment Terms Table and ZTERM Texts Table for ABAP Developers
How to Create SAPScript Text using SO10 Transaction Code
SAP Smartforms Tutorial - Table Calculations using Sum Total
SAP Smartforms Tutorial - Table Calculations using Count
SAP Smartforms Tutorial - How to Create Smartform
SAP NetWeaver Installation Guide using installshield wizard
SAP Smartforms Table for Sales Order and Invoice Outputs
Email Spool Request using SAPOffice - Spool to PDF
How to Display SAP Graphics using SE78 Transaction Code
SAPScript Transaction Codes
ABAP Tutorial - ABAP String Split Example Code
Sales Tables among ABAP Tables (SAP Sales and Distribution SD Tables)
How to Upload Data to SAP from Excel File using alsm_excel_to_internal_table Function Module
ALV Grid Color - Table Row Background Color in ALV List
Multi Color ALV Grid Color Alternate using ALV Layout info_fname Property
How to Debug SmartForms - Debugging SAP SmartForm in ABAP ?
ABAP - Create Hierarchy Tree List using rs_tree_construct, rs_tree_list_display and snodetext
Create CL_GUI_ALV_GRID ALV Grid Column Header using ABAP Data Element
ABAP Tutorial - SAP Split and ABAP Split String Function
Upload Data from Excel File in ABAP using TEXT_CONVERT_XLS_TO_SAP
SAP Tutorial - Convert Spool Request to PDF File using RSTXPDFT4 ABAP Report
SAP ABAP Tutorial - ALV Grid Example with cl_gui_alv_grid and Screen Painter
Convert Smartform to PDF in Print Preview Mode
SAP Smartforms Tutorial - Create Smartforms Example
SAP Smartforms - How to Call Smartform within ABAP Program
Complete List of SAP Modules






Copyright © 2004 - 2013 Eralper Yilmaz. All rights reserved.
Community Server by Telligent Systems