The requirement is very basic:
I need to create a sap bex user exit.
I need to have a ABAP code that automatically tells me which period a petculiar date belongs to. So let's say if today is 3-25-2014. I need a code that could subtract one period from current date and then figure out what quarter the new period belongs to.
Example: today's date is 3/25/2014 minus 1 period is 2/25/2014 so the quarter would be 1.
Another example, date is 5-5-2014
Minus 1 period is 4-5-2014
So the quarter would be 2.
Period 1-3 = 1
Period 4-6 = 2
Period 7-9 = 3
Period 10-12 = 4
Let me know if this is possible,
Thank you, and always I appreciate your help.
Below is the code I have writtien so far. I dont know why it does not work.
WHEN 'ZHR_QTR_001'. "
IF I_STEP = 2.
READ TABLE I_T_VAR_RANGE INTO LOC_T_VAR_RANGE
WITH KEY VNAM = 'ZSYDATE'.
IF SY-SUBRC = 0.
data: l_month type p decimals 2,
l_quarter type i.
l_month = LOC_T_VAR_RANGE-LOW+4(2).
if l_month = '01'.
l_quarter = '4'.
else.
l_quarter = trunc( ( l_month - 1 ) / 3 ) + 1.
endif.
l_s_range-low = l_quarter.
APPEND L_S_RANGE TO E_T_RANGE.
ENDIF.
ENDIF.