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: 

Set dynamic variant for time

former_member194669
Active Contributor
0 Kudos

Hi,

I have selection options for field as defined as TIME . I need to set dynamic variant for this field as

TIME should be "from"='current time-30 minutes' and "to"='24:59:59'.

This report going to run in 00 hours and 30 hours (48 times ie 24 X 2)

PS : Pl. remember this is for a SAP standard report

Any Info?

1 ACCEPTED SOLUTION

naimesh_patel
Active Contributor
0 Kudos

I guess it would not be possible with standard avaliable options to dynamically populate both time fields.

There is a underlying FM behind all the dynamic calculations in Variants.

Like:

For calculation (of Time - Type Z) "From Start of Day to Now", underlying FM is RS_VARI_V_TIME_00_UP_TO_NOW.

I digged more deeper and found one FM RS_VARI_V_INIT_TIME which fill the options like Current Time, Current Time +/- ???, From Start of Day to Now etc. and Surprisinly all 3 options are hardcoded in it..!!

So, if you modify this FM to include your FM with Custom Calculation than this option would come into the calculation options and would work when you select that variant. I have tried this in debugging and it is working..!! For this test, I copied FM RS_VARI_V_TIME_00_UP_TO_NOW to my Z and changed the logic. I put a break-point in RS_VARI_V_INIT_TIME to fill a new line with my Z FM.

Regards,

Naimesh Patel

9 REPLIES 9

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Create a wrapper program which calculates the specific time, then do a SUBMIT on the standard report and pass the parameters to that program.

Regards,

Rich Heilman

0 Kudos

Rich,

Thanks for your reply. Your suggestion will work if program is scheduled as standalone My problem is this program is called inside another program , before submitting the program , they are reading variant values.

Say for example

A is my program. it has been called in B , before calling A in B , they used RS_VARIANT_READ, so here it is getting failed.

I am working PI 7.1 system.

naimesh_patel
Active Contributor
0 Kudos

Use Dynamic Time Calculation in the Variant.

In the Variant maintenance screen, under the

Selection Variable: select Z - Dynamic Time Calculation

Name of Variable:

Select "Current Time +/- ??? " from F4

Enter

'-' in +/-

00 in HH

30 in MM

Regards,

Naimesh Patel

0 Kudos

Naimesh,

As per your suggestion, system is setting the value only LOW and HIGH is blank.

0 Kudos

There is something I don't understand.

You can't change program B ?

Could you show abap code of program B, how does it call A ?

former_member226234
Contributor
0 Kudos

Deleted

Edited by: Sandeep Kadamb on Jan 13, 2009 8:16 PM

naimesh_patel
Active Contributor
0 Kudos

I guess it would not be possible with standard avaliable options to dynamically populate both time fields.

There is a underlying FM behind all the dynamic calculations in Variants.

Like:

For calculation (of Time - Type Z) "From Start of Day to Now", underlying FM is RS_VARI_V_TIME_00_UP_TO_NOW.

I digged more deeper and found one FM RS_VARI_V_INIT_TIME which fill the options like Current Time, Current Time +/- ???, From Start of Day to Now etc. and Surprisinly all 3 options are hardcoded in it..!!

So, if you modify this FM to include your FM with Custom Calculation than this option would come into the calculation options and would work when you select that variant. I have tried this in debugging and it is working..!! For this test, I copied FM RS_VARI_V_TIME_00_UP_TO_NOW to my Z and changed the logic. I put a break-point in RS_VARI_V_INIT_TIME to fill a new line with my Z FM.

Regards,

Naimesh Patel

0 Kudos

> I digged more deeper and found one FM RS_VARI_V_INIT_TIME which fill the options like Current Time, Current Time +/- ???, From Start of Day to Now etc. and Surprisinly all 3 options are hardcoded in it..!!

As you suggested due to hardcoded values here , we could not able to do much on this.

So i came in round away solution. Whenever program A called ( program with TIME selection input) i have called another custom program C . (This custom program will using the following function module RS_VARIANT_CONTENTS, and RS_VARIANT_CHANGE , So get the DEFAULT variant content of program A and change the variant content with LOW as current time - 30 and HIGH with 24:59:59) as preceding job.

In PI 7.01 system program A always called in JOB mode

Thanks for info.

0 Kudos

Good workaround..!

Regards,

Naimesh Patel