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 variant - time variable

Former Member
0 Kudos

Hello!

I want to create a variant for an IDoc housekeeping program (rbdmani2) and I want to save the following in a program variant:

For the current date (I have managed to use a dynamic variable for this) and IDocs created in the past hour, i.e. the select option for Creation time should be "from"='current time-1hour' and "to"='current time'.

How can I express current time minus 1 hour and the current time respectively?

Please advice. Thanks!

::Ellen

6 REPLIES 6

Former Member
0 Kudos

Hi,

This link may help you..

Regards,

Sailaja.

Reward points to helpful answers.

Former Member
0 Kudos

Ellen - what do you want to do if the current time is say 00:30:00 (half past midnight)? Do you need to look at the date as well?

Rob

0 Kudos

I think you may want something like:


REPORT ztest NO STANDARD PAGE HEADING LINE-SIZE 135 LINE-COUNT 65.

DATA: cur_date LIKE sy-datum,
      pre_date LIKE sy-datum,
      cur_time LIKE sy-uzeit,
      pre_time LIKE sy-uzeit.

cur_date = sy-datum.
cur_time = sy-uzeit.

pre_date = cur_date.
IF cur_time(2) = '00'.
  pre_date = pre_date - 1.
  pre_time = cur_time + 82800.
ELSE.
  pre_time = cur_time - 3600.
ENDIF.

Rob

0 Kudos

hi,

You can't perform the dynamic calculation on the TIME selection fields. That is possible only for DATE fields. So you may have to write a custom wrapper program with same selection screen as RBDMANI2 and then call program RBDMANI2 using SUBMIT from your custom program.

In your custom program, you can set the time values in the Initialization block as

S_TIME-low = sy-uzeit - 60.

s_time-high = sy-uzeit.

In the variant you are going to create, for the time field select as P - "Save Field without values". This way the values maintained in the initialization blcok won't be overwritten by the variant. Hoep this helps

But you still need to consider the issue raised by Rob for the past midnight run scenario. Whatever we do, we can't handle the midnight scenario, unless you want to break it as two runs, one for prior to midnight and another for after midnight. This can be possible by putting some logic in the custom program to check time and call the RBDMANI2 twice.

Hari

0 Kudos

Hari - I don't see a problem using time fields in calculations. You do have to make sure that you don't go past or before midnight. And you have to remember that the basic unit is the second, so that to add an hour, you have to add 3600 to the time.

Rob

0 Kudos

Hi Rob,

I meant we can't avoid running the program past midnight most of the times. SO i was suggesting a way to come around this issue if we the past midnight scenario can't be avoided.

Hari