Skip to Content

Whenever we have to run an SAP Program for which selection data needs to be entered, and in case same data needs to be entered along with the program run for every run, SAP offers option to save sets of input values for programs as “variants”. Therefore, an SAP Program and a variant name can be provided to setup a batch job; the variant taking care of the selection data in the program fields.

Sometimes a few fields in such variants need not keep the same data for the frequent run, but there is a need for “dynamic” update of selection data, for example dates. So a batch job will be scheduled as a one-time activity but for today’s run it takes a particular date; and for tomorrow’s run, it takes updated and new date, without the need to enter or update the variant every day. This is the concept of “dynamic variants” which we shall discuss in this document.

Process to create a dynamic variant is explained as follows:

1. Go to SE38 transaction; enter Program name and execute; then enter all the values in the input fields which are needed and click on “Save” button.

2. System will take you to variant screen; enter the name and description of the variant.

/wp-content/uploads/2015/03/1_669316.jpg

[Image 1- Variant attributes]

3. Select the line of your date – options field from the list and scroll right

4. Double click on “selection variable” column and select “D”

/wp-content/uploads/2015/03/2_669407.jpg

[Image 2- Variant attributes]

5. Double click on “Name of variable” last column and select “Current date – xxx,current date + yyy” system will provide you popup with “Enter a value xxx” and “Enter a value for yyy” and enter value 7 in xxx and 0 in yyy and save the variant .

/wp-content/uploads/2015/03/3_669408.jpg

[Image 3- Variant attributes]

After making the above changes, the “date range” in the date field will keep updating itself as “7 days before current date (date on which program will be run as part of batch job)” till “current date”, meaning it will select last 1 week.

/wp-content/uploads/2015/03/4_669409.jpg

[Image 4- Variant attributes]

Similarly, we can use any other options available in the screen, as per our requirement, namely:

  1. Current Date
  2. From month start to today
  3. Current date +/- ??? days
  4. current date +/- ??? work days
  5. First day of current month
  6. nth working day of current month
  7. First day of next month
  8. First day of previous month
  9. Last day of previous month
  10. Last Day of the Current Month
  11. First quarter ????
  12. Second quarter ????
  13. Third quarter ????
  14. Fourth quarter ????
  15. Current date – xxx,current date + yyy
  16. Date – xxx, Date + yyy (work days)
  17. Previous month
  18. Current period
  19. (Beginning of mth-xx months, end of mth+yy months)

Therefore, using any of the above options available, we can create a dynamic variable suitable for our respective needs.

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

Comments are closed.