Application Development and Automation 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: 
Read only

Dynamic date in variant

Former Member
0 Likes
2,329

Hi,

I need to create a dynamic date for my variant.

Date will be the select option - The from date should be the current date and the to date should be current date + 30 days.

When i am using the Selection variant and using the option D to calculate the current date+ 30 days. But that is getting stored in the from date but not in the to-date. My report will be running in back ground every day. So according to the requirment i need to have from date as current date and to-date as current date + 30 days.

I cannot use the logic in initialization as the report will be running based on the variant saved.

Thanks,

Raju

Hi,

I need to create a dynamic date for my variant.

Date will be the select option - The from date should be the current date and the to date should be current date + 30 days.

When i am using the Selection variant and using the option D to calculate the current date+ 30 days. But that is getting stored in the from date but not in the to-date. My report will be running in back ground every day. So according to the requirment i need to have from date as current date and to-date as current date + 30 days.

I cannot use the logic in initialization as the report will be running based on the variant saved.

Thanks,

Raju

6 REPLIES 6
Read only

Former Member
0 Likes
1,704

Hi,

In the event initialization, u need to put values in the date variables.

eg . if you select-option is s_date

then write following code in initialization

s_date-low = sy-datum.

v_date = sy-datum + 30.

s_date-high = v_date

Hope this solves ur problem.

Cheers,

Raj

Read only

0 Likes
1,704

Hi Rajat,

As i mentioned i can not put the logic in Initialization as my report will be running in background every day.

Pls let me know how to save the variant so that i can have both from and to dates in the variant.

Currently i am able to get the current day + 30 days in the from date but i want the from date to be current date and the to date to be current date + 30 days.

Thanks,

Raju

Read only

0 Likes
1,704

Hi Raju,

Use this function module in your program.

ADD_TIME_TO_DATE.

In this function module, enter the period you need to add to the export parameter I_TIME.


CALL FUNCTION 'ADD_TIME_TO_DATE'

EXPORTING

I_IDATE = SY-DATUM

I_TIME = '30'

I_IPRKZ = ' '

IMPORTING

O_IDATE = date .

WRITE:/ DATE .

Hope it helps.

Regards,

Raj

Edited by: Raj Karunanidhi on Jan 7, 2010 11:36 AM

Edited by: Raj Karunanidhi on Jan 7, 2010 11:37 AM

Read only

0 Likes
1,704

Hi Raj,

I can think of one thing,

just use parameters for start date and end date

and then set the their values in the variant as follows,

Press Save on the selection Screen and then put the name and short text then,

in the very last box called "Selection screen objects 1000" check on the fourth check box "Selection variable" for both start date and end date.

Then click on "selection Variable" Button on left hand top corner of the screen.

Then click on the 😧 Dynamic date calculation the must turn Green.

then click on the downward arrow that appears there you will have options to set the date.

there choose current date for the start date and Current date +/- ??? days for the end date.

now while setting the end date it will ask you the number of days there you have to put 30(as it is your requirement) and SAVE.

Then test it .

otherwise you can go for this approach. Keep your date in select-options only and use the following option while selecting "Selection variables"

"Current date - xxx,current date + yyy"

Hope it helps you,

Regards,

Abhijit G. Borkar

Edited by: Abhijit Borkar on Jan 7, 2010 7:31 AM

Read only

vinod_vemuru2
Active Contributor
0 Likes
1,704

Hi,

I have posted a blog on the same topic. Please check below link.

/people/vinod.vemuru2/blog/2010/01/04/how-to-create-a-dynamic-variant-and-setup-batch-job-with-dynamic-variant

Thanks,

Vinod.

Read only

Former Member
0 Likes
1,704

Try this. It will work. I checked it.


AT SELECTION-SCREEN OUTPUT.

REFRESH s_date.

  s_date-low = sy-datum.
  s_date-high = sy-datum + 30.

  APPEND s_date.