Ansicht
Dokumentation

EXIT_SAPLRSTH_002 -

EXIT_SAPLRSTH_002 -

BAL_S_LOG - Application Log: Log header data   BAL_S_LOG - Application Log: Log header data  
This documentation is copyright by SAP AG.
SAP E-Book

SAP exit: BRSTEX01, function exit EXIT_SAPLRSTH_002

Self-defined hierarchies

1. Application area of the function exit EXIT_SAPLRSTH_002 in LIS

In the Logistics Information System, you can perform a hierarchy drill-down as part of the standard analysis and in accordance with the hierarchies predefined by SAP (e.g. vendor class or product group).

You also have the option of creating customer specific hierarchies (for individual characteristics in an info structure) which are known as General Hierarchies. (Menu path: Logistics -> Logistics Controlling -> e.g. Purchasing Info System -> Environment -> General hierarchy -> Create). It is then possible to drill down according to these hierarchies in the standard analysis.

The general hierarchy option enables you to create any variety of hierarchies for the characteristic "material", for example. Here, every material number to be included in the hierarchy has to be assigned to one fixed hierarchy node.

The above function exit also enables you to set up customer-specific hierarchies. In contrast to the general hierarchies, however, you do not need to assign the individual characteristic values (such as material number) to specific hierarchy nodes. You can use virtually any ABAP/4 routine to calculate which characteristic values belong to the respective hierarchy nodes. (This means that the hierarchy can be defined using an algorithm). The hierarchy is set up dynamically (i.e. not until runtime) using the characteristic values selected from the standard analysis with the help of this ABAP/4 routine in this function exit.

This function exit enables you to define a hierarchy for the characteristic MATNR (material), for instance, and the way in which it is allocated to the individual hierarchy nodes can be derived dynamically from the material number. This is possible, for example, when the material number contains a distribution which follows the hierarchy, i.e. when you can use the material number to establish the hierarchy node to which the respective material belongs.

2. Parameters

Import parameters:

  • I_RSTHVKEY,,: name of the selected hierarchy
  • I_RSTHIE,,,,: the standard analysis uses this table to transfer the characteristic values you have chosen to the function exit.
  • I_SEL,,,,: objects in the current drill-down path. Example: If you have performed a drill down on vendor L1 (data element in the info structure = LIFNR) according to material M2 (data element = MATNR) and then drill down on M2, I_SEL will contain the following characters: LIFNR#L1#MATNR#M2
The string of characters saved in variable I_SEL can be broken down by using the following ABAP/4 instructions
DATA: BEGIN OF ITAB OCCURS 10,
FIELD(30),
END OF ITAB.
SPLIT I_SEL AT '#' INTO TABLE ITAB.
Each section of the character chain separated by '#' then becomes a separate line of the table ITAB.

Export parameters:

  • I_RSTHIE,,,,: the function exit uses this table to transfer the hierarchy tree to the standard analysis. This means that I_RSTHIE is both an import and export parameter.
  • I_RSTTYP,,,,: table containing information on the hierarchy nodes. (You can find a detailed explanation of the contents of I_RSTTYP below.)

All other parameters of the function exit are not required.

3. Procedure

3.1 Introducing the hierarchy to the standard analysis

You first need to define the hierarchy. You can do this by maintaining the view VTRSTHVMCS in Customizing or by using transaction SM30. Here you have to enter either the data element or the domain of the characteristic for which a hierarchy drill-down is to be possible. You therefore need to maintain either the "Data element" field or the "Domain" field, and in doing so, please observe the following:

If you fill the "Data element" field, a hierarchy drill-down is then possible in all info structures containing a characteristic that refers to this data element.

If you fill the "Domain" field, a hierarchy drill-down is then possible in all info structures containing a characteristic whose data element has the domain that you specified.

3.2 Transferring the data from the standard analysis to the function exit

If the user chooses a self-defined hierarchy during the "hierarchy drill-down" in the standard analysis, then the standard analysis transfers all chosen characteristic values in the table I_RSTHIE to the above function exit. The function exit sets up the hierarchy you require from these characteristic values and then transfers it back to the standard analysis.

The following example explains the subsequent procedure:

4. Example: "Material group" hierarchy

4.1 Description

This example is based on the hierarchy illustrated below, which contains the materials M1, M2, ... , M8 and both hierarchy levels "main material group" (Main Group) and "material group" (Group). The materials M7 and M8 are not assigned to any hierarchy nodes.

                   Main Group 1         Main Group 2
                      /     \                 !
                     /       \                !
                Group 1.1   Group 1.2      Group 2.1
                    !        /  \          /  !  \
                    !       /    \        /   !   \
                   M1      M2    M3     M4   M5    M6     M7    M8

If the standard analysis has selected the materials M1, M3, M4, M5, M6, M7, M8, these six materials are transferred to the function exit via the table I_RSTHIE; ONLY the field NAME is filled here.

        Table I_RSTHIE:      ID  TYPE  NAME
                                         M1
                                         M4
                                         M5
                                         M6
                                         M7
                                         M8

The function exit then has to derive the following tree from the data entered and the hierarchy definition:

                                 ~ROOT
                               /   !   \
                            /      !      \
                         /         !         \
              Main Group 1   Main Group 2   ~NON_HIER
                     /             !          !   !
                    /              !          !   !
                Group 1.1       Group 2.1     !   !
                   !           /   !  \       !   !
                   !          /    !   \      !   !
                  M1        M4    M5   M6     M7  M8

A hierarchy tree must always possess the artificial root node ~ROOT. All subordinate subtrees are allocated to this node. This root node is also necessary, however, when there is only one subtree.

As long as there are materials that are not assigned to a hierarchy node (such as M7 and M8 above), you can use the artificial node ~NON_HIER for them, provided that these materials are to be visible in the standard analysis.

4.2 Output of the function exit (in the above example)

4.2.1 Table I_RSTHIE:

The function exit has to fill the following fields in table I_RSTHIE:

  • I_RSTHIE-TYPE : Node type (e.g. 'M' for material, 'G' for group)
  • I_RSTHIE-NAME : Key of the node (e.g. 'M1', 'Group 1')
  • I_RSTHIE-LEVEL : Level of the node in the tree

The hierarchy tree has to be transferred to the internal table I_RSTHIE in a left recursive way. This means that the table must have the following contents:

             TYPE    NAME         TLEVEL
             ROOT    ~ROOT        1
             MG      MainGroup 1  2
             G       Group 1.1    3
             M       M1           4
             MG      MainGroup 2  2
             G       Group 2.1    3
             M       M4           4
             M       M5           4
             M       M6           4
             NONH    ~NON_HIER    2
             M       M7           3
             M       M8           3

The predefined names (ROOT, ~ROOT, NONH und ~NON_HIER) must be identified by the accompanying constants that are defined in Include LRSTHTP1. This avoids the chance of typing errors which could have a lasting effect.

4.2.2 Table I_RSTTYP:

Table I_RSTTYP describes the levels in the hierarchy contained in table I_RSTHIE. The field TYPE describes the type, ROLNM the data element and DOMN the domain of the respective hierarchy level. The field TDOMNM defines the technical domain from which the text for the hierachy nodes are determined in the standard analysis.

Table I_RSTTYP would look as follows for the above example:

           TYPE   ROLNM    DOMNM    TDOMNM    HPOST
           MG     MGroup   MGroup   MGroup
           G      ZGroup   ZGroup   ZGroup
           M      MATNR    MATNR    MATNR     X

The field I_RSTTYP-HPOST contains the value X if the corresponding node type contains values in the info structure. This usually only applies to the end nodes of the tree. The following example, however, explains a situation in which it is also necessary to mark a hierarchy node with an 'X'. This involves a customer hierarchy with customers K1, K2, K3 and K4 (refer to the following illustration).

                        K1
                     /  !  \
                   K2  K3  K4

In this hierarchy, hierarchy nodes (such as K1) can have values in the in the underlying information structure. This means that it is a "postable" hierarchy.

If the key figure "invoiced sales" had the value $40 in K1, $10 in K2, $20 in K3, and $30 in K4, the standard analysis for K1 would show invoiced sales to be $100, because a postable hierarchy is involved. When a total of the key figure is made, not only the values of the respective, directly dependent nodes, but also the key figure value of the hierarchy node itself are included in the total. For this reason, it is advisable to organize the above hierarchy as follows:

                       K1
                    / / \ \
                   /  !  !  \
                 K1  K2  K3  K4.

If the hierarchy has this structure, then customers K1 through K4 appear once a drill-down is performed on customer K1 in the higher-level drill-down list. This means that all of the characteristics (customers) whose key figure values were included in the total for the higher level would appear in the drill-down list.

In this case, the contents of table I_RSTHIE would be as follows:

                    TYPE    NAME        TLEVEL
                    ROOT    ~ROOT       1
                    MC      K1          2
                    C       K1          3
                    C       K2          3
                    C       K3          3
                    C       K4          3

5. Multiple allocations (Links)

5.1 Multiple allocations of end nodes

If an end node (e.g. a material number) is to be assigned to more than one hierarchy node (e.g. material groups), then you need to enter this end node more than once in the internal table I_RSTHIE.

5.2 Multiple allocations of hierarchy nodes

If a hierarchy node (e.g. material group) is to be assigned to more than one hierarchy node (e.g. main material groups), than you can do this by means of so-called links. In this function exit, you can use additional hierarchy nodes to insert such links. In the following illustration, the hierarchy node 4 is allocated to the higher nodes 1 and 2. You can break down this multiple allocation into individual nodes by using an additional node 4, which refers to the actual node 4. In the case of the additional node, you need to set the field LINK to 'X'. (See the following structure of the table I_RSTHIE).

            ~ROOT                               ~ROOT
           /     \                            /      \
          /       \                          /         \
         1         2        ==>            1            2
       /   \     /  \                     /  \         /  \
      /     \  /     \                   /    \       /     \
     3       4        5                 3      4<----4       5
     !      / \       !                 !     / \            !
     M1    M2 M3      M4               M1    M2 M3           M4

Table I_RSTHIE:                     TYPE   NAME     TLEVEL  LINK
                                      ROOT   ~ROOT    1
                                      A      1        2
                                      B      3        3
                                      M      M1       4
                                      B      4        3
                                      M      M2       4
                                      M      M3       4
                                      A      2        2
                                      B      4        3       X
                                      B      5        3
                                      M      M4       4






BAL Application Log Documentation   Fill RESBD Structure from EBP Component Structure  
This documentation is copyright by SAP AG.

Length: 28126 Date: 20240416 Time: 213739     sap01-206 ( 222 ms )