Skip to Content
0
Jun 13, 2022 at 07:44 PM

Customer exit to get data from 1st month to entered month

100 Views Last edit Jun 14, 2022 at 11:20 AM 2 rev

Hello Experts , I need a Customer exit to fetch data from 1st month of the year to Entered month (based on FISCPER)

For example - If I enter May I should get all the data from January to May

Currently this is the code I have written (Variable = ZVAR_FISCPER1)

Please help me with correct logic


DATA:
l_s_range TYPE rrrangesid,
loc_var_range LIKE rrrangeexit,
lv_month TYPE d,
lv_year(4) TYPE n,
lv_first_month TYPE sy-datum,
lv_last_month TYPE sy-datum.

*To Calculate First Month of the year
CASE i_vnam.

WHEN 'ZVAR_FISCPER1'.
IF i_step = 2.
LOOP AT i_t_var_range into loc_var_range WHERE vnam = 'ZVAR_FISCPER1'.

lv_month = loc_var_range-low+4(2).
lv_year = loc_var_range-low+0(4).

CONCATENATE lv_year '01' INTO lv_month.
CALL FUNCTION 'CACS_DATE_GET_YEAR_MONTH'
EXPORTING
day_in = lv_first_month
IMPORTING
last_month_of_year = lv_last_month.
l_s_range-low = lv_first_month.
l_s_range-high = lv_last_month.
l_s_range-sign = 'I'.
l_s_range-opt = 'BT'.

APPEND l_s_range TO e_t_range.
ENDLOOP.
ENDIF.
ENDCASE.

endmethod.