Skip to Content
avatar image
Former Member

data till last day in Bex (MTD)

Hi grurus,

Please help me to provide the step to get data One day before in mTD dta ..As user required to get the current MTD as the day from 1st day of the month till yesterday ..Not Today..I have already created a current MTD field in Bex query which gives data from the 1st day of the month till today..

suppose he is running a report today(6/8/2017) so MTD will give from 1st day may till 6/7/2017)

Please Advise.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    Jun 13, 2017 at 09:45 AM

    Dear Siddique,

    Please use the code as mentioned below for your variable

    Say you have chosen the variable for MTD as ZCAL_MTD.

    WHEN 'ZCAL_MTD'.
    v_loc_date = sy-datum.
    v_loc_date1 = sy-datum - 1.
    l_s_range-low = v_loc_date.
    l_s_range-high = v_loc_date1.
    l_s_range-low+0(4) = sy-datum+0(4).
    l_s_range-low+4(2) = sy-datum+4(2).
    l_s_range-low+6(2) = '01'.
    l_s_range-sign = 'I'.
    l_s_range-opt = 'BT'.
    APPEND l_s_range TO e_t_range_c.
    EXIT.

    Regards,

    Add comment
    10|10000 characters needed characters exceeded

  • Jun 13, 2017 at 03:21 AM

    Hi Siddique,

    In the e_t_range Internal table , Please give the high field values as sy-datum - 1, it will work now.

    Regards,

    RC.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 22, 2017 at 07:44 AM

    Thanks for you help..

    Add comment
    10|10000 characters needed characters exceeded

  • Jun 27, 2017 at 07:05 AM

    Hi,

    Use the code below. It also caters the MTD for every 1st day of month which will have the result of full month last month.


    gv_date type sy-datum.

    WHEN 'ZCAL_MTD'.
    gv_date = sy-datum - 1.
    concatenate gv_date(6) '01' into L_S_RANGE-LOW.
    L_S_RANGE-HIGH = gv_date.
    L_S_RANGE-SIGN = 'I'.
    L_S_RANGE-OPT = 'BT'.
    APPEND L_S_RANGE TO E_T_RANGE.
    ENDLOOP.


    Regards,

    Loed

    Add comment
    10|10000 characters needed characters exceeded