SAP BW DTP Filter with Routine

In my current project I have to filter data with a lot of logic. So I build some ABAP routines in a DTP filter to receive the necessary data. First you have to open the DataTransferProcess (DTP) in change mode and select the Filter button on the Extraction tab.

DTP Extraction tab
DTP Extraction tab

Then use the small icon on the right and create a routine.

DTP Filter
DTP Filter

Enter a name for the routine and you see the following screen.

Create ABAP routine
Create ABAP routine

And now we have the full power of ABAP to build some really cool stuff. My example is we read a hierarchy and select all leaves under a node and set the DTP Filter with it. Or you read the attributes of an InfoObject and select all entries which are equal to the attributes and enter them into the filter.

CONSTANTS: lc_iobjnm_zsaleschannel TYPE rsiobjnm VALUE 'ZSALESCHANNEL'.

 

DATA:

ls_rssh_hiedir TYPE rshiedir,

lt_rssh_hiedir TYPE rssh_t_hiedir,

ls_subtreesel TYPE rssh_s_nodebyname,

lt_hierarchy TYPE /bic/whzsaleschannel,

 

FIELD-SYMBOLS:

<ls_hierarchy> TYPE /bic/hzsaleschannel,

 

'Get all hierarchies from the object

CALL FUNCTION 'RSSH_HIER_OF_IOBJ_GET'

EXPORTING

i_objvers = rs_c_objvers-active

i_iobjnm = lc_iobjnm_zsaleschannel

i_langu = sy-langu

IMPORTING

e_t_rshiedir = lt_rssh_hiedir.

 

'Get technical hierarchy id to hierarchy name

CLEAR ls_rssh_hiedir.

 

READ TABLE lt_rssh_hiedir INTO ls_rssh_hiedir WITH KEY hienm = i_zsaleschannel_h

 objvers = rs_c_objvers-active.

 

'Sub-Tree to Note/Leaf

CLEAR: ls_subtreesel.

ls_subtreesel-iobjnm = lc_iobjnm_zsaleschannel

ls_subtreesel-nodename = i_node.

 

*Get Hierarchy Elements

CALL METHOD cl_rssh_hierarchy_func=>get

EXPORTING

i_objvers = rs_c_objvers-active

i_hieid = ls_rssh_hiedir-hieid

i_s_subtreesel = ls_subtreesel

IMPORTING

e_t_hiestrucall = lt_hierachy

After I have now all elements in an internal table, I can add them to the DTP Filter.

'Loop over the internal table and assign the value to the dtp filter

LOOP AT lt_hierarchy ASSIGNING <ls_hierarchy>.

l_t_range-fieldname = '/BIC/ZSALESCHANNEL'.

l_t_range-iobjnm = '/BIC/ZSALESCHANNEL'.

l_t_range-sign = 'I'.

l_t_range-option = 'EQ'.

l_t_range-low = <ls_hierarchy>-/bic/zsaleschannel.

 

IF l_idx <> 0.

MODIFY l_t_range INDEX l_idx.

ELSE.

APPEND l_t_range.

ENDIF.

 ENDLOOP.

DTP with active ABAP method
DTP with active ABAP method

author.


I am Tobias, I write this blog since 2014, you can find me on twitter and youtube. If you want you can leave me a paypal coffee donation. You can also contact me directly if you want.

Analysis Office - The Comprehensive Guide 3rd edit
Analysis Office - The Comprehensive Guide is a pdf book about SAP BusinessObjects Analysis Office. It is based on Analysis Office 2.6 and contains 272 Pages.
49,99 €
Analysis Office - The Comprehensive Guide 2nd edit
Analysis Office - The Comprehensive Guide is a pdf book about SAP BusinessObjects Analysis Office. It is based on Analysis Office 2.4 and contains 243 pages.
39,99 €
Analysis Office - The Comprehensive Guide
Analysis Office - The Comprehensive Guide is a pdf book about SAP BusinessObjects Analysis Office. It is based on Analysis Office 2.3 and contains 227 Pages.
9,99 €

Write a comment

Comments: 0