Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Multipe filters on Hierarchy nodes in DTP

Hello Everybody,

I need your help:

I need to filter in a DTP on several Hierarchy nodes.

I have tried to do it with an OLAP Variable but it did not work.

FIRST QUESTION:

is it possible to do that with an OLAP variable? how should I set up the variable?

Since I am not a programmer, can you help me with the code - if I have to create a customer Exit variable?

SECOND QUESTION

if I can not create an OLAP VAR - shall I do it directly in the DTP? is it possible?

Can you provide me with the code pls? I need to filter on different  ( 10 ) nodes of the Hierachy - I have googled it but not found any clear response

I really appreciate your help

many thanks

Manu

replied

Hi Manu,

Please find below a coding example I previously created to flatten a Hierarchy on 0ACCOUNT. I tried to modify the coding so that it can be used in a DTP Filter routine.

You will have to slightly adapt it to make it work in your case (e.g. InfoObject, Hierarchy name, Node names).

* Local data declaration

  DATA:

    l_s_hiesel       TYPE rsndi_s_hiesel,

    l_s_subtreesel   TYPE rssh_s_nodebynamewol,

    l_subrc          TYPE sy-subrc,

    l_t_nodenames    TYPE STANDARD TABLE OF rsndi_s_nodenm,

    l_s_accountrange TYPE rs_s_range,

    l_t_accountrange TYPE STANDARD TABLE OF rs_s_range,

    l_chaval_low     TYPE rsshchavalue,

    l_s_range    TYPE rssdlrange.

  FIELD-SYMBOLS:

    <nodenames>      TYPE rsndi_s_nodenm,

    <accountrange>   TYPE rs_s_range.

* Initialization

  CLEAR:

    l_s_hiesel,

    l_s_subtreesel,

    l_subrc.

  REFRESH:

    l_t_nodenames,

    l_t_accountrange.

* Determine Accounts from Hierarchy Node

  l_s_hiesel-objvers      = rs_c_objvers-active.

  l_s_hiesel-hienm        = i_hienm.      "<<< replace with your hierarchy

  l_s_hiesel-dateto       = '99991231'.

  l_s_hiesel-iobjnm       = '0ACCOUNT'.

  l_s_subtreesel-nodename = i_nodename.   "<<< replace with respective node

  l_s_subtreesel-iobjnm   = '0HIER_NODE'.

  CALL FUNCTION 'RSNDI_SHIE_STRUCTURE_GET3'

    EXPORTING

      i_s_hiesel        = l_s_hiesel

      i_s_subtreesel    = l_s_subtreesel

      i_no_nodenm_table = rs_c_false

    IMPORTING

      e_subrc           = l_subrc

    TABLES

      e_t_nodenames     = l_t_nodenames.

  IF l_subrc <> 0.

    p_subrc = 4.

    RETURN.

  ENDIF.

  DELETE l_t_nodenames WHERE iobjnm = '0HIER_NODE' OR iobjnm = '0CHRT_ACCTS'.

  SORT l_t_nodenames BY nodeid fromto.

  LOOP AT l_t_nodenames ASSIGNING <nodenames>.

    CASE <nodenames>-fromto.

      WHEN ' '.              "no interval

        CLEAR l_s_accountrange.

        l_s_accountrange-sign = rs_c_range_sign-including.

        l_s_accountrange-opt  = rs_c_range_opt-equal.

        l_s_accountrange-low  = <nodenames>-chavalue.

        APPEND l_s_accountrange TO l_t_accountrange.

      WHEN '1'.              "interval from-value

        l_chaval_low = <nodenames>-chavalue.

      WHEN '2'.              "interval to-value

        CLEAR l_s_accountrange.

        l_s_accountrange-sign = rs_c_range_sign-including.

        l_s_accountrange-opt  = rs_c_range_opt-between.

        l_s_accountrange-low  = l_chaval_low.

        l_s_accountrange-high = <nodenames>-chavalue.

        APPEND l_s_accountrange TO l_t_accountrange.

        CLEAR l_chaval_low.

    ENDCASE.

  ENDLOOP.

* Fill range

  LOOP AT l_t_accountrange ASSIGNING <accountrange>.

    CLEAR l_s_range.

    l_s_range-fieldname = i_fieldnm.

    l_s_range-sign      = <accountrange>-sign.

    l_s_range-option    = <accountrange>-opt.

    l_s_range-low       = <accountrange>-low.

    l_s_range-high      = <accountrange>-high.

    APPEND l_s_range TO l_t_range.

  ENDLOOP.

* Set return code to OK

  p_subrc = 0.

Best regards,

Sander

1 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question