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: 

dynamic date range in the variant

Former Member
0 Kudos
5,577

Hi,

We have a background job that is scheduled to run on every 25th. One step of the job has a selection screen which has a Payment date range which is to have the dates 25th of previous to the 24th of the current month.

So every month this needs to be updated dynamically. For ex: If I look at the variant of the step of the job in period 04 the date should be "03/25/2010 to 04/24/2010". If I look in Period 05 then it should be "04/25/2010 to 04/25/2010".

Can anyone tell me if this can be achieved through a variant or does this have to be put in the code?

Regards,

raj/

1 ACCEPTED SOLUTION

Former Member
0 Kudos
1,169

Hi Raj,

Instead of variant, what you can do is,

1) In the Initialisation event of the report, do the calculation to get these dates using system date.

2) Set these dates as defualt at on selection screen.

Let me know if you need more details.

Regards,

Sumit

14 REPLIES 14

Former Member
0 Kudos
1,170

Hi Raj,

Instead of variant, what you can do is,

1) In the Initialisation event of the report, do the calculation to get these dates using system date.

2) Set these dates as defualt at on selection screen.

Let me know if you need more details.

Regards,

Sumit

Former Member
0 Kudos
1,169

Try this..

report ZTEST_SUMIT.

DATA: DATE_TEMP LIKE SY-DATUM.

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-000.
PARAMETERS: DATE1 TYPE SY-DATUM.
PARAMETERS: DATE2 TYPE SY-DATUM.
SELECTION-SCREEN END OF BLOCK B1.

INITIALIZATION.


DATA : TEMP_DATE_C(10), TEMP_MONTH_PREV_C(2), TEMP_MONTH_C(2).
DATA : TEMP_MONTH_PREV TYPE I, TEMP_MONTH TYPE I.
TEMP_DATE_C = SY-DATUM.
TEMP_MONTH_C = TEMP_DATE_C+4(2).
TEMP_MONTH = TEMP_MONTH_C.

TEMP_MONTH_PREV = TEMP_MONTH - 1.
TEMP_MONTH_PREV_C = TEMP_MONTH_PREV.

CONCATENATE '0' TEMP_MONTH_PREV_C INTO TEMP_MONTH_PREV_C.

CONCATENATE '2010' TEMP_MONTH_PREV_C '25' INTO TEMP_DATE_C." SEPARATED BY '.'.
DATE1 = TEMP_DATE_C.
CLEAR TEMP_DATE_C.
CONCATENATE '2010' TEMP_MONTH_C '24' INTO TEMP_DATE_C." SEPARATED BY '.'.
DATE2 = TEMP_DATE_C.
CLEAR TEMP_DATE_C.

Regards,

Sumit

satyajit_mohapatra
Active Contributor
0 Kudos
1,169

You can maintain the values of select options or parameters in TVARVC through transaction STVARV. You can change it dynamically for each run of the program. Also, in initialization event you need to get the values stored in TVARVC.

0 Kudos
1,169

Satyajit,

Can you please explain the concept of TVARVC a bit in detail?

Raj/

0 Kudos
1,169

I would say the best approach would be the one suggested by Sumit.

Read the SAP documentation if you are still interested in TVARVC: [http://help.sap.com/saphelp_nw70/helpdata/en/c0/9803ade58611d194cc00a0c94260a5/frameset.htm]

@Satyajit: I don't see the point how you intend to make the variant dynamic by storing values in TVARVC ?

Edited by: Suhas Saha on Apr 28, 2010 7:13 PM

0 Kudos
1,169

Under the selection variant attributes screen, the column 'selection variable' = 'T' (T: Table Variable from TVARVC) will allow the selection field to be assigned the TVARVC variable under column 'Name of Variable (Input Only Using F4)'.

Former Member
0 Kudos
1,169

Hi,

Schedule to job for every 25th of the month and then you can create a dynamic variant (Selection variable "D") with system date - 30days. For more information refer the below link on how to create a dynamic variant.

http://divulgesap.com/blog.php?p=MTM=

Hope it helps.

Regards,

Ravikiran

satyajit_mohapatra
Active Contributor
0 Kudos
1,169

You can create a dynamic variant using STVARV following the steps in the given link...

http://wiki.sdn.sap.com/wiki/display/ABAP/Creatingdynamicvariantusingtable+TVARV

Now, the values in TVARVC need to be updated for each period. It can be done scheduling a separate BDC program, which runs for each period and updates the values. So, your date values will be changed for a new period by the background job and program variant wil pick up automatically the values from TVARVC. Check this link, which depicts a similar kind of requirement.

You can also calculate the values in intialization event each time the program runs as suggested by Sumit. But, if you need a variant then it won't help. The advantage with TVARVC is you can maintain different set of variants with different values.

0 Kudos
1,169

>

> Now, the values in TVARVC need to be updated for each period. It can be done scheduling a separate BDC program, which runs for each period and updates the values.

You are suggesting to create another program to update TVARVC ? Did you think about the maintenance overhead before suggesting this solution ?

>

> But, if you need a variant then it won't help. The advantage with TVARVC is you can maintain different set of variants with different values.

Do you need a variant if your selection-screen parameters are automatically populated ? I don't think so.

0 Kudos
1,169
 Absolutely!! What is the point in increasing so many dependencies! 
schedule a BDC to update TVARVC. Then transport. Again keep monitoring it. The day your background process fails, TVARVC wont update!
Instead why dont you just add the code and retransport! No dependencies!

Regards,

Sumit Nene

0 Kudos
1,169

I completely agree with you. But, variants are required in some the cases, where different users want to have different variants for thier use.

For example, my client had different divisions and they always insisted for different variant for each division and used TVARVC to maintain them.

The same can be achieved through code, but for each change in selection requirement the enhancement needs to be done in the report.

But in this case, if the report needs to be run for a calculated value for every user, then there is no need of maintaining TVARVC.

former_member206439
Contributor
0 Kudos
1,169

Hi Please find the below steps :-

1. Execute the report and you will get your selection screen then press save

2. system will take u to variant screen , select the line of your date select-options field from the list and scroll right

3. double clik on "selection variable " column and select "D"

4. double clik 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 1 in xxx and 0 in yyy

and save the variant . now your S_DATE_LOW will be system date - 1 ie yesterdays date

"Current date - xxx,current date + yyy" system will provide you popup with "Enter a value xxx" and "Enter a value for yyy"

and here XXX is S_DATE-LOW and YYY is for S_DATE-HIGH . and enter values in these will provide you dynamic variant.

Thanks

Naresh

0 Kudos
1,169

Hi ,

I have a field in my variant which is set to D selection variable.  But I need to pass different value for the field in the existing variant.

But I am getting default value from the calculation mentioned in  Variant attributes.

Kindly share if there is any option to change the value of specific field which has selection variable D.

Regards,

Kirthi

gajendra_moond
Contributor
0 Kudos
1,169

Hi Raj

See if this helps!