HOw To Filter in DTP Using ABAP
HOw To Filter in DTP Using ABAP
Example:
If today’s date is 04/22/2016, based on the system date, it will calculate previous month First day and Last
day. i.e. it will fetch 03/01/2016 to 03/31/2016.
If today’s date is 01/22/2016, based on the system date, it will calculate previous month First day and Last
day. i.e. it will fetch 12/01/2015 to 12/31/2015.
Occasionally we need to filter the Date Characteristic InfoObject to extract only “Previous Month” data. Here the filter
selection is not on SAP Content InfoObject, the filter selection is on Custom InfoObject.
If it is SAP Content InfoObject, we may have few SAP Customer exit/variables to use directly in DTP, but in this
example I’m using Custom InfoObject which is created Data Type as DATS.
In DTP select the InfoObject and choose Create Routine and write/add the below Code in DTP Routine.
*$*$ end of global – insert your declaration only before this line *-*
*$*$ begin of routine – insert your code only below this line *-*
data: l_idx like sy–tabix.
read table l_t_range with key
fieldname = ‘ ‘.
l_idx = sy–tabix.
*….
CALL FUNCTION ‘RS_VARI_V_LAST_MONTH’
* EXPORTING
* SYSTIME =‘‘
TABLES
p_datetab = dt_range
p_intrange = btw.
READ TABLE dt_range INTO wdt_range INDEX 1.
l_t_range–fieldname = ‘/BIC/<Your_InfoObject_Name>’.
l_t_range–option = ‘BT’.
l_t_range–sign = ‘I’.
l_t_range–low = wdt_range–low.
l_t_range–high = wdt_range–high.
APPEND l_t_range.
* IF l_idx <> 0.
* MODIFY l_t_range INDEX l_idx.
* ELSE.
* APPEND l_t_range.
* ENDIF.
*$*$ end of routine – insert your code only before this line *-*
Approach 1
Write routine at DTP level for 0CALMOTH InfoObject :
l_t_range-fieldname = 'CALMONTH'.
l_t_range-option = 'EQ'.
l_t_range-sign = 'I'.
l_t_range-low = SY-DATUM+0(6).
append l_t_range.
Approach 2