cancel
Showing results for 
Search instead for 
Did you mean: 

FM RP_CALC_DATE_IN_INTERVAL is not exist in BW

Former Member
0 Kudos

Hi Experts,

Is there any FM equivalent to this function Module RP_CALC_DATE_IN_INTERVAL? ,

In my Scenario the report has to run fetching data based on current date -1 i.e if I run the report on 30.06.2015 the report should get the data from 29.06.2015 and also for previous 3 months ( MAR,APR,MAY).

I am facing issue if I run for the month of MAY, or any previous month because of the FEBRUARY month. How to fix this issue.

Regards

Bhaskar

Accepted Solutions (1)

Accepted Solutions (1)

Loed
Active Contributor
0 Kudos

Hi,

Did you follow my suggestion with your other thread?

It already caters your problem with February..

Regards,

Loed

Former Member
0 Kudos

Dear Loed,

Yes I am working on it my friend. PFA of my report .

I have created 4 Variable :

For calday:

  1. ZVAR_VA1
  2. ZVAR_VA2
  3. ZVAR_VA3
  4. ZVAR_VA4

For CALMONTH:

  • ZMTD_VA1

WHEN 'ZVAR_VA1'.

     IF I_STEP = 2.

       IF SY-DATUM+6(2) >= 1.

         READ TABLE I_T_VAR_RANGE INTO WA_RANGE1
         WITH KEY VNAM = 'ZMTD_VAR'.

         LV_CMON = WA_RANGE1-LOW+4(2).
         lv_cyer = WA_RANGE1-LOW+0(4).

         concatenate lv_cyer LV_CMON '01' into lv_day1.

         lv_date1 = SY-DATUM+6(2) - 1.
         concatenate lv_cyer LV_CMON lv_date1 into lv_day2.

         WA_RANGE-LOW = lv_day1.
         WA_RANGE-HIGH = lv_day2.
         WA_RANGE-SIGN = 'I'.
         WA_RANGE-OPT = 'BT'.
         append WA_RANGE to e_t_range.

       ELSEIF SY-DATUM+6(2) = 1.

         READ TABLE I_T_VAR_RANGE INTO WA_RANGE1
         WITH KEY VNAM = 'ZMTD_VAR'.

         LV_CMON = WA_RANGE1-LOW+4(2).
         lv_cyer = WA_RANGE1-LOW+0(4).

         lv_cmon1 = lv_cmon - 1.
         lv_date2 = sy-datum+6(2).
         concatenate lv_cyer LV_CMON1 '01' into lv_day1.
         concatenate lv_cyer LV_CMON1 lv_date2 into lv_day2.

         CALL FUNCTION 'SLS_MISC_GET_LAST_DAY_OF_MONTH'
           EXPORTING
             DAY_IN            = lv_day2
           IMPORTING
             LAST_DAY_OF_MONTH = lv_day3
           EXCEPTIONS
             DAY_IN_NOT_VALID  = 1
             OTHERS            = 2.

         WA_RANGE-LOW = lv_day1.
         WA_RANGE-HIGH = lv_day3.
         WA_RANGE-SIGN = 'I'.
         WA_RANGE-OPT = 'BT'.
         append WA_RANGE to e_t_range.

       ENDIF.
     ENDIF.


   WHEN 'ZVAR_VA2'.

     IF I_STEP = 2.

       IF SY-DATUM+6(2) >= 1.

         READ TABLE I_T_VAR_RANGE INTO WA_RANGE1
         WITH KEY VNAM = 'ZMTD_VAR'.

         LV_CMON = WA_RANGE1-LOW+4(2).
         lv_cyer = WA_RANGE1-LOW+0(4).

         LV_CMON2 = LV_CMON - 1.

         concatenate lv_cyer LV_CMON2 '01' into lv_day1.

         lv_date1 = SY-DATUM+6(2) - 1.
         concatenate lv_cyer LV_CMON2  lv_date1 into lv_day2.


         WA_RANGE-LOW = lv_day1.
         WA_RANGE-HIGH = lv_day2.
         WA_RANGE-SIGN = 'I'.
         WA_RANGE-OPT = 'BT'.
         append WA_RANGE to e_t_range.

       ELSEIF SY-DATUM+6(2) = 1.

         READ TABLE I_T_VAR_RANGE INTO WA_RANGE1
         WITH KEY VNAM = 'ZMTD_VAR'.

         LV_CMON = WA_RANGE1-LOW+4(2).
         lv_cyer = WA_RANGE1-LOW+0(4).

         lv_cmon1 = lv_cmon - 2.
         lv_date2 = sy-datum+6(2).
         concatenate lv_cyer LV_CMON1 '01' into lv_day1.
         concatenate lv_cyer LV_CMON1 lv_date2 into lv_day2.

         CALL FUNCTION 'SLS_MISC_GET_LAST_DAY_OF_MONTH'
           EXPORTING
             DAY_IN            = lv_day2
           IMPORTING
             LAST_DAY_OF_MONTH = lv_day3
           EXCEPTIONS
             DAY_IN_NOT_VALID  = 1
             OTHERS            = 2.

         WA_RANGE-LOW = lv_day1.
         WA_RANGE-HIGH = lv_day3.
         WA_RANGE-SIGN = 'I'.
         WA_RANGE-OPT = 'BT'.
         append WA_RANGE to e_t_range.

       ENDIF.
     ENDIF.

   WHEN 'ZVAR_VA3'.

     IF I_STEP = 2.

       IF SY-DATUM+6(2) >= 1.

         READ TABLE I_T_VAR_RANGE INTO WA_RANGE1
         WITH KEY VNAM = 'ZMTD_VAR'.

         LV_CMON = WA_RANGE1-LOW+4(2).
         lv_cyer = WA_RANGE1-LOW+0(4).

         LV_CMON2 = LV_CMON - 2.

         concatenate lv_cyer LV_CMON2 '01' into lv_day1.

         lv_date1 = SY-DATUM+6(2) - 1.
         concatenate lv_cyer LV_CMON2 lv_date1 into lv_day2.


         WA_RANGE-LOW = lv_day1.
         WA_RANGE-HIGH = lv_day2.
         WA_RANGE-SIGN = 'I'.
         WA_RANGE-OPT = 'BT'.
         append WA_RANGE to e_t_range.

       ELSEIF SY-DATUM+6(2) = 1.

         READ TABLE I_T_VAR_RANGE INTO WA_RANGE1
         WITH KEY VNAM = 'ZMTD_VAR'.

         LV_CMON = WA_RANGE1-LOW+4(2) .
         lv_cyer = WA_RANGE1-LOW+0(4).

         lv_cmon1 = lv_cmon - 3.
         lv_date2 = sy-datum+6(2).
         concatenate lv_cyer LV_CMON1 '01' into lv_day1.
         concatenate lv_cyer LV_CMON1 lv_date2 into lv_day2.

         CALL FUNCTION 'SLS_MISC_GET_LAST_DAY_OF_MONTH'
           EXPORTING
             DAY_IN            = lv_day2
           IMPORTING
             LAST_DAY_OF_MONTH = lv_day3
           EXCEPTIONS
             DAY_IN_NOT_VALID  = 1
             OTHERS            = 2.

         WA_RANGE-LOW = lv_day1.
         WA_RANGE-HIGH = lv_day3.
         WA_RANGE-SIGN = 'I'.
         WA_RANGE-OPT = 'BT'.
         append WA_RANGE to e_t_range.

       ENDIF.
     ENDIF.

   WHEN 'ZVAR_VA4'.

     IF I_STEP = 2.

       IF SY-DATUM+6(2) >= 1.

         READ TABLE I_T_VAR_RANGE INTO WA_RANGE1
         WITH KEY VNAM = 'ZMTD_VAR'.

         LV_CMON = WA_RANGE1-LOW+4(2).
         lv_cyer = WA_RANGE1-LOW+0(4).

         lv_cmon2 = lv_cmon - 3.
         concatenate lv_cyer LV_CMON2 '01' into lv_day1.

         lv_date1 = SY-DATUM+6(2) - 1.
         concatenate lv_cyer LV_CMON2 lv_date1 into lv_day2.


         WA_RANGE-LOW = lv_day1.
         WA_RANGE-HIGH = lv_day2.
         WA_RANGE-SIGN = 'I'.
         WA_RANGE-OPT = 'BT'.
         append WA_RANGE to e_t_range.

       ELSEIF SY-DATUM+6(2) = 1.

         READ TABLE I_T_VAR_RANGE INTO WA_RANGE1
         WITH KEY VNAM = 'ZMTD_VAR'.

         LV_CMON = WA_RANGE1-LOW+4(2).
         lv_cyer = WA_RANGE1-LOW+0(4).

         lv_cmon1 = lv_cmon - 4.
         lv_date2 = sy-datum+6(2).
         concatenate lv_cyer LV_CMON1 '01' into lv_day1.
         concatenate lv_cyer LV_CMON1 lv_date2 into lv_day2.

         CALL FUNCTION 'SLS_MISC_GET_LAST_DAY_OF_MONTH'
           EXPORTING
             DAY_IN            = lv_day2
           IMPORTING
             LAST_DAY_OF_MONTH = lv_day3
           EXCEPTIONS
             DAY_IN_NOT_VALID  = 1
             OTHERS            = 2.

         WA_RANGE-LOW = lv_day1.
         WA_RANGE-HIGH = lv_day3.
         WA_RANGE-SIGN = 'I'.
         WA_RANGE-OPT = 'BT'.
         append WA_RANGE to e_t_range.

       ENDIF.
     ENDIF.
ENDCASE.


My entire CMOD Code.


Regards

Bhaskar

Loed
Active Contributor
0 Kudos

Hi,

If you don't want my solution from your other thread, check this, I revised your code..You may use this as your sample to revise your other variables..

DATA: temp_start like sy-datum,

temp_end like sy-datum,

temp_loc like sy-datum.

WHEN 'ZVAR_VA4'.


if i_step = 2.

READ TABLE I_T_VAR_RANGE INTO WA_RANGE1 WITH KEY VNAM = 'ZMTD_VAR'.

CLEAR L_S_RANGE.

        temp_loc = sy-datum - 1.


        concatenate  WA_RANGE1-LOW(6) '01' into temp_start.

        temp_start = temp_start - 1.

        concatenate temp_start(6) '01' into temp_start.

        temp_start = temp_start - 1.

        concatenate temp_start(6) '01' into temp_start.

        temp_start = temp_start - 1.

        concatenate temp_start(6) '01' into temp_start.


        concatenate temp_start(6) temp_loc+6(2) into temp_end.

        L_S_RANGE-LOW         = temp_start.

        L_S_RANGE-HIGH        = temp_end.

        L_S_RANGE-SIGN        = 'I'.

        L_S_RANGE-OPT         = 'BT'.

        APPEND L_S_RANGE TO E_T_RANGE.

exit.

endloop.

endif.


Regards,

Loed

Loed
Active Contributor
0 Kudos

Hi,

I already did the other three (3) variables:

DATA: temp_start like sy-datum,

temp_end like sy-datum,

temp_loc like sy-datum.

WHEN 'ZVAR_VA3'.


if i_step = 2.

READ TABLE I_T_VAR_RANGE INTO WA_RANGE1 WITH KEY VNAM = 'ZMTD_VAR'.

 

CLEAR L_S_RANGE.

        temp_loc = sy-datum - 1.


        concatenate  WA_RANGE1-LOW(6) '01' into temp_start.

        temp_start = temp_start - 1.

        concatenate temp_start(6) '01' into temp_start.

        temp_start = temp_start - 1.

        concatenate temp_start(6) '01' into temp_start.


        concatenate temp_start(6) temp_loc+6(2) into temp_end.

        L_S_RANGE-LOW         = temp_start.

        L_S_RANGE-HIGH        = temp_end.

        L_S_RANGE-SIGN        = 'I'.

        L_S_RANGE-OPT         = 'BT'.

        APPEND L_S_RANGE TO E_T_RANGE.

exit.

endloop.

endif.

DATA: temp_start like sy-datum,

temp_end like sy-datum,

temp_loc like sy-datum.

WHEN 'ZVAR_VA2'.


if i_step = 2.

READ TABLE I_T_VAR_RANGE INTO WA_RANGE1 WITH KEY VNAM = 'ZMTD_VAR'.

 

CLEAR L_S_RANGE.

        temp_loc = sy-datum - 1.


        concatenate  WA_RANGE1-LOW(6) '01' into temp_start.

        temp_start = temp_start - 1.

        concatenate temp_start(6) '01' into temp_start.


        concatenate temp_start(6) temp_loc+6(2) into temp_end.

        L_S_RANGE-LOW         = temp_start.

        L_S_RANGE-HIGH        = temp_end.

        L_S_RANGE-SIGN        = 'I'.

        L_S_RANGE-OPT         = 'BT'.

        APPEND L_S_RANGE TO E_T_RANGE.

exit.

endloop.

endif.









DATA: temp_start like sy-datum,

temp_end like sy-datum,

temp_loc like sy-datum.

WHEN 'ZVAR_VA1'.


if i_step = 2.

READ TABLE I_T_VAR_RANGE INTO WA_RANGE1 WITH KEY VNAM = 'ZMTD_VAR'.

 

CLEAR L_S_RANGE.

        temp_loc = sy-datum - 1.


        concatenate  WA_RANGE1-LOW(6) '01' into temp_start.


        concatenate temp_start(6) temp_loc+6(2) into temp_end.

        L_S_RANGE-LOW         = temp_start.

        L_S_RANGE-HIGH        = temp_end.

        L_S_RANGE-SIGN        = 'I'.

        L_S_RANGE-OPT         = 'BT'.

        APPEND L_S_RANGE TO E_T_RANGE.

exit.

endloop.

endif.




Just post here for any question..

Regards,

Loed

Answers (2)

Answers (2)

Loed
Active Contributor
0 Kudos

Hi,

How's your problem? Did the code work?

Regards,

Loed

Former Member
0 Kudos

Dear Loed,

Yeah your code really helped me to fix the issue. With the help of your code input i was able to achieve the requirement.Thanks a lot for your timely help..

Regards

Bhaskar

Loed
Active Contributor
0 Kudos

Hi,

Good to know that the code worked for you,,

Regards,

Loed

Former Member
0 Kudos

Hi Loed,

Thanks for your support.

Regards

Bhaskar

Former Member
0 Kudos

Hi Gnana,

Use FM - SEPA_MANDATE_ADD_MONTH_TO_DATE

First subtract 1 from today's date. Then pass '-3' to MONTHS  and date to OLDDATE. You will get correct value in NEWDATE.

Something like:

olddate = sy-datum - 1.


   CALL FUNCTION 'SEPA_MANDATE_ADD_MONTH_TO_DATE'

   EXPORTING

     months        = -4

     olddate       = olddate

  IMPORTING

    NEWDATE       = NEWDATE

           .

You may need to play with Months value as -4 or -3 to get the desired no. of month back.

Thanks

Amit