Skip to Content
0

variable of date calculation

Apr 28, 2017 at 06:42 AM

117

avatar image
Former Member

Hi,

i am trying to create a new variant to select date range:

From: current date -1

To : End of month

I don't see variable in the list to meet above requirement.

Would you please advise, on how shall I create a new variable?

best regards,

Rtn

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Jelena Perfiljeva
May 02, 2017 at 08:24 PM
2

How are the variables defined in the program? PARAMETERS or SELECT-OPTIONS?

If it's PARAMETERS (i.e. two variables - from and to) then you can use in the variant dynamic variables "current date - 1" and "Last day of current month".

If it's SELECT-OPTIONS then your dynamic variable options are limited to just one. In this case either you could fill in values in the program, as shown by John (in this case you won't use variant to determine those values, so be careful when saving a variant for other values) or you'll have to create a custom variable. (option T in the variant). The latter has been discussed numerous times on SCN. Google -> TVARVC site:sap.com.

Kindly make sure to search and read documentation before posting in SCN.

P.S. "month" in SAP could also be fiscal, not calendar month. Make sure to clarify that.

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi,

It's PARAMETERS: Two variables-From and To, how to use in the variant dynamic variable "Current date-1" and "Last day of current month"? I don't see in SAP.

Thanks,
Ratana

0

Where exactly are you looking "in SAP"? It's in the variant, under selection variable -> dynamic date calculation, at least in ECC 6.0.

0
avatar image
Former Member Apr 28, 2017 at 10:42 AM
-3

Hi Ratana,

SAP variant do not support current your requirement. If you you are using the customize report, you can do sample code abap below.

REPORT  zzzztest.
SELECT-OPTIONS: s_day  FOR sy-datum.



DATA : lv_lastday_month  TYPE sy-datum.



INITIALIZATION.

  CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'

    EXPORTING

      day_in            = sy-datum

    IMPORTING

      last_day_of_month = lv_lastday_month.

  s_day-sign = 'I'.

  s_day-option = 'EQ'.

  s_day-low = sy-datum - 1.

  s_day-high = lv_lastday_month. " last day of month

  APPEND s_day.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

It should be "BT" instead of "EQ". "EQ" will give you exactly two days, not the period in between.

1