Hi All,
I have a requirement where based on user input data on calendar date ( IDATE) 01.01.2013 - 01.03.2013 , we need to take the high value of date from that we need to display two columns , one column should show the last 3 months period data and second coulmn should display data for last 6 months.
Problem is when query is showing data only for first two months of period i.e. 001.2013 and 002.2013.
We created two variable as reference characteristics as fiscper and processing by customer exit.
please find the below code and out put , but when i make a check in RSRT with key figure definition is coming correctly where it is calculating properly for 3 month and 6 months data.
IF i_step EQ 2.
CASE i_vnam.
WHEN 'NXXV6MON'.
CLEAR: ls_var_range, lv_date,lv_pre_period, lv_res_date.
* Read input variable Reporting Fiscal Year/Period
READ TABLE i_t_var_range_c WITH KEY vnam = 'IDATE'
INTO ls_var_range.
IF sy-subrc EQ 0.
lv_date = ls_var_range-high.
lv_curr_year = lv_date+0(4).
lv_curr_period = lv_date+4(2).
CALL FUNCTION 'DATE_CREATE'
EXPORTING
ANZAHL_JAHRE = 0
ANZAHL_KALTAGE = 0
ANZAHL_MONATE = -5
ANZAHL_TAGE = 0
DATUM_EIN = lv_date
* DATUM_EIN_ULT = ' '
* ULTIMO_SETZEN = ' '
IMPORTING
DATUM_AUS = lv_res_date.
* E_TT =
* E_ULTKZ
lv_pre_period = lv_res_date+4(2).
lv_pre_year = lv_res_date+0(4).
CONCATENATE lv_pre_year lv_pre_period into lv_result_pre.
CONCATENATE lv_curr_year lv_curr_period into lv_result_pre1.
ls_range-sign = 'I'.
ls_range-opt = 'BT'.
ls_range-low = lv_result_pre.
ls_range-high = lv_result_pre1.
* ls_range-low = '2016001'.
* ls_range-high = '2016002'.
APPEND ls_range TO e_t_range_c.
ENDIF.
WHEN 'NXX3MON'.
CLEAR: ls_var_range, lv_date,lv_pre_period, lv_res_date.
* Read input variable Reporting Fiscal Year/Period
READ TABLE i_t_var_range_c WITH KEY vnam = 'IDATE'
INTO ls_var_range.
IF sy-subrc EQ 0.
lv_date = ls_var_range-high.
lv_curr_year = lv_date+0(4).
lv_curr_period = lv_date+4(2).
CALL FUNCTION 'DATE_CREATE'
EXPORTING
ANZAHL_JAHRE = 0
ANZAHL_KALTAGE = 0
ANZAHL_MONATE = -2
ANZAHL_TAGE = 0
DATUM_EIN = lv_date
* DATUM_EIN_ULT = ' '
* ULTIMO_SETZEN = ' '
IMPORTING
DATUM_AUS = lv_res_date.
* E_TT =
* E_ULTKZ
lv_pre_period = lv_res_date+4(2).
lv_pre_year = lv_res_date+0(4).
CONCATENATE lv_pre_year lv_pre_period into lv_result_pre.
CONCATENATE lv_curr_year lv_curr_period into lv_result_pre1.
ls_range-sign = 'I'.
ls_range-opt = 'BT'.
* ls_range-low = '2016001'.
** ls_range-high = ''.
ls_range-low = lv_result_pre.
ls_range-high = lv_result_pre1.
APPEND ls_range TO e_t_range_c.
ENDIF.
Out put
out is showing only two fiscal year period data 001.2013 and 002.2013, but our requirement should display last 6 months 010.2012 to 003.2013
and last three months 001.2013 to 003.2013