Skip to Content
0

Infoobject - Dynamic Hierarchy - populate entries

Apr 20, 2017 at 10:33 AM

182

avatar image

Hello,

Is it possible to display the content of infoobject hierarchy with custom code where i will populate the content of hierarchy(or even hierarchy itself)? Currently we have manually maintained the hierarchy and it's entries, but this is static list. I am looking for something where i will be able to decide/code what/how it can be displayed via query. or may be can we overwrite the hierarchy table itself when populating?

Remote Hier. Class / Hier. Class Parameters, I thought this option will option will work.. but i didnt find any documentation.

I have read few blogs here, most of the blogs actually defines the hierarhy and it's entries.

any thougts from where I can start with?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Andrey Uryukin Apr 25, 2017 at 09:30 AM
0

Hi,

Virtual hierarchy with remote class will definately work.

The only point that you have to consider is that object can have either real heirarchy or virtual.

So if you have a standard hierarchy loaded from ECC (lets say hierarchy of cost center) then you can't use a virtual approach in the same object.

I will give you an example of what I used to do:

There was an object with any existing hierarchy.

The requirement was to show a sub hierarchy in F4 and report without showing a root of the main hierarchy.

I created a shadow object (not reference) and implemented virtual hierarchy (took as example one of standard classes shown in F4, guess from CL_RSRTS_HIERARCHY_SFLIGHT).

The main part in the code is IF_RRHI_VIRT_HIER-GET_HIER method.

Here I have first to select sub-hierarchy (let's say only subordinate employees of the particular manager) from the existing physical hierarchy and then move it, with a slight modifications, to a virtual hierarchy.

Please see a "rough" example of my implementation of IF_RRHI_VIRT_HIER-GET_HIER:

    SELECT *
      FROM /bic/hzPHYSICAL_HIERARCHY_TABLE
      INTO TABLE lt_virt_hier
      FOR ALL ENTRIES IN ANY_TABLE_WITH_RESTRICTED_VALUES
      WHERE hieid     = PHYSICAL_HIERARCHY_ID AND
            nodename  = ANY_TABLE_WITH_RESTRICTED_VALUES-nodename.

    SORT lt_virt_hier BY tlevel ASCENDING.
    lv_min_level = lt_emp_hier[ 1 ]-tlevel.
    lv_min_level = lv_min_level - 2.

    e_th_hienode =  VALUE #( FOR <fs> IN lt_virt_hier
                              (
                                hieid    = p_hieid
                                objvers  = rs_c_objvers-active
                                nodeid   = <fs>-nodeid
                                iobjnm   = 'YOUR_VIRTUAL_HIERARCHY_IO_TECH_NAME'
                                nodename = <fs>-nodename
                                parentid = COND #( WHEN <fs>-tlevel - lv_min_level = 2 THEN '1' ELSE <fs>-parentid )
                                tlevel   = <fs>-tlevel - lv_min_level
                                childid  = <fs>-childid
                                nextid   = <fs>-nextid
                               )
                            ).

    l_s_hienode-hieid    = p_hieid.
    l_s_hienode-objvers  = rs_c_objvers-active.
    l_s_hienode-nodeid   = 1.
    l_s_hienode-iobjnm   = '0HIER_NODE'.
    l_s_hienode-nodename = 'ANY TITLE FOR VIRTUAL HIERARCHY ROOT'.
    l_s_hienode-tlevel   = 1.
    l_s_hienode-childid  = lt_virt_hier[ nodename = FIRST_MEMBER_OF_RESTRICTED_TABLE ]-nodeid.
    INSERT l_s_hienode INTO TABLE e_th_hienode.

You can take it as a basis ...

BR,

Show 3 Share
10 |10000 characters needed characters left characters exceeded

Thank you Andrey. I will check this thing.

0

Andrey,

I have created an infoobject and assigned a remote hierarchy class with Hierarchy interfaces and used this in a query.

I have loaded some entries for this infoobject.

when i execute a query, this method IF_RRHI_VIRT_HIERARCHIES~GET_CAPABILITIES gets called every time.

Is there any prerequisite or configuration?

Is there any importance of Hier. Class Parameter? I am not able to edit it.

I am trying to figure out, how IF_RRHI_VIRT_HIER-GET_HIER will be triggered.

0

I'm not sure if you need GET_CAPABILITIES method.

The following methods I left unchanged:

IF_RRHI_VIRT_HIERARCHIES~GET_HEADER_WITH_HIENM IF_RRHI_VIRT_HIERARCHIES~GET_HEADER_WITH_HIEID

IF_RRHI_VIRT_HIER~CREATE

IF_RRHI_VIRT_HIER~GET_TIMESTAMP

IF_RRHI_VIRT_HIER~GET_TEXTS

IF_RRHI_VIRT_HIER~GET_LEVEL_INFO

the following methods I set empty:

IF_RRHI_VIRT_HIERARCHIES~GET_CAPABILITIES

IF_RRHI_VIRT_HIERARCHIES~GET_HEADERS

I only changed the following methods:

IF_RRHI_VIRT_HIER~GET_HIER

_GET_HIEDIR

Regarding GET_HIER the code is above.

In _GET_HIEDIR I just corrected e_s_hiedir-hieid = 'NAME OF MY HIERARCHY'.

0