0% found this document useful (0 votes)
95 views2 pages

HOw To Filter in DTP Using ABAP

Uploaded by

ajoylal01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
95 views2 pages

HOw To Filter in DTP Using ABAP

Uploaded by

ajoylal01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Scenario: If I execute DTP in current month, it always picks only “Current month – 1” data.

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.

* Global code used by conversion rules


*$*$ begin of global – insert your declaration only below this line *-*
* TABLES: …

DATA: dt_range TYPE STANDARD TABLE OF rsdatrange,


btw LIKE STANDARD TABLE OF rsintrange,
wdt_range TYPE rsdatrange.

*$*$ 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

Write below code in Start Routine


Data: calmon type /BI0/OICALMONTH
clear: calmon.
calmon = sy-datum+0(6).
DELETE SOURCE_PACKAGE WHERE CALMONTH NE calmon.

You might also like