Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Change variant to consider 01.01.current year

Former Member
0 Kudos

Hi,

I need to adjust the variant key date to '01.01.current year' (dynamically). I tried different options using Table Variable from TVARC but not able to adjust. I should not write this in the program. Requirement is to update the variant. Please let me know how to achieve this.

Regards

Kishor

1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor

As this variable "first day of year" does not exist, neither in table of variable nor in dynamic functions, you have to maintain it yourself in TVARVC thru a customer program executed by a periodic job and then use this new variable in your variant.

NB: You can copy code of standard report RVSETDAT to update TVARVC, add your z-report to the background job which currently (should) execute this standard report everyday in your system.

Regards,

Raymond

9 REPLIES 9

rajkumarnarasimman
Active Contributor
0 Kudos

Hi Kishor,

Without using TVARC Table, we have another option called Dynamic date calculation .

When creating variant, In selection variable, use D as shown below. Than lead to assign the dynamic date in variant as shown below.

In this case, I have selected first day of current month.

First date of Current year is not available in this case, I hope normally we schedule the program in background, Some program will run once in a year on January month. In those case, we may need first date value 01.01.2015. In some day it is going to run on January month, it is better to assign the variant (First day of Current Month) as shown above.

If the program is ran on any day in January month, we can use value as 01.01.2015 for this year.. For next year 01.01.2016.

Hope it helps.

Regards

Rajkumar Narasimman

0 Kudos

Hi Rajkumar,

Thanks for the info. But as per the requirement, I need to set the date as day one of current year (irrespective of month - It should not consider only january month) in the variant. Is there any possibility to create a variable for this in TVARC table.

Regards

Kishor

0 Kudos

Hi Kishor,

You can use "RS_CREATE_VARIANT"  Function module to create a dynamic variant for your program.


Call the function module at initialization event and create a variant based on the year.

Regards.

Praveer.


0 Kudos

Hi Praveer,

Variant is already available in the system and I need to update the date field with 01.01.current year when the variant is selected.

Regards

Kishro

0 Kudos

Hi,

Please find the below code, which will create a variant at initialization stage of the program.

In above code, write the logic to set the Date Parameters based on the Current Year.

Low = sy-datum+0(4) && '0101'.

Reagards.

Praveer

0 Kudos

Hi Kishor,

you can use RS_VARIANT_DELETE  function module to delete the existing and then update with New Information by the same coding, what i have provided.

So everytime, user will get the new Variant with same name, only the variant value will be change, as per Date Information.

Regards.

Praveer.

raymond_giuseppi
Active Contributor

As this variable "first day of year" does not exist, neither in table of variable nor in dynamic functions, you have to maintain it yourself in TVARVC thru a customer program executed by a periodic job and then use this new variable in your variant.

NB: You can copy code of standard report RVSETDAT to update TVARVC, add your z-report to the background job which currently (should) execute this standard report everyday in your system.

Regards,

Raymond

0 Kudos

Thanks for the suggestions. I got the answer.

In Initialization I have added the code to default the key date value to 01.01.Current year and in the variant for this key date  I have selected the check box ‘Save field without values’. So the key date value was filled with 01.01.Current year in the given variant.

Regards

Kishor

JaySchwendemann
Active Contributor
0 Kudos

This is an oldie but since it is one of the first hits in Google... After your kindergarden child grew to a teenager, there's a solution to this: https://launchpad.support.sap.com/#/notes/3103263

Cheers

Jens