Quantcast
Channel: SCN : Discussion List - SAP Business Warehouse
Viewing all articles
Browse latest Browse all 6437

flattening hierarchy of 0COSTELMNT

$
0
0

Hi experts

 

We have the same scenario as described in this blog:

http://scn.sap.com/docs/DOC-48062

 

We only need node level 6 and 7 of cost element hierarchy.

I have applied the coding as of the blog, but the routine doesn't finish,

 

Is there any additional coding or corrections to make?

Thanks.


    FIELD-SYMBOLS:
      <RESULT_FIELDS>    TYPE _ty_s_TG_1.

    DATA:
      MONITOR_REC     TYPE rstmonitor.

*$*$ begin of routine - insert your code only below this line        *-*
    ... "insert your code here
*--  fill table "MONITOR" with values of structure "MONITOR_REC"
*-   to make monitor entries
    ... "to cancel the update process
*    raise exception type CX_RSROUT_ABORT.

 

    TYPES: BEGIN OF lty_final,
            COSTELMNT    TYPE RSSHNODENAME,
            lvl6_nodname TYPE RSSHNODENAME,
            lvl7_nodname TYPE RSSHNODENAME,
           END OF lty_final.

 

    DATA:   lw_costel  TYPE /BI0/HCOSTELMNT,
            lw_costel1 TYPE /BI0/HCOSTELMNT,
            lw_final   TYPE lty_final,
            lt_final   TYPE STANDARD TABLE OF lty_final,
            lv_hieid   TYPE rshieid,
            lt_costel TYPE STANDARD TABLE OF /BI0/HCOSTELMNT,
            lt_costel1 TYPE STANDARD TABLE OF /BI0/HCOSTELMNT,
            lv_parentid TYPE rsparent,
            lv_strlen   TYPE n LENGTH 2.

 

    CLEAR: lw_costel1, lw_costel, lw_final, lv_parentid.

 

    SELECT SINGLE hieid
      FROM /BI0/HCOSTELMNT
      INTO lv_hieid
      WHERE nodename = 'PRIM' AND OBJVERS = 'A'.


    IF sy-subrc NE 0.
      CLEAR lv_hieid.


    ELSE.

 

      SELECT * FROM /BI0/HCOSTELMNT
       INTO TABLE lt_costel
       WHERE hieid EQ lv_hieid.
      IF sy-subrc EQ 0.
        lt_costel1[] = lt_costel[].
        SORT lt_costel1 BY nodeid.
        SORT lt_costel BY iobjnm DESCENDING tlevel DESCENDING.

 

        LOOP AT lt_costel INTO lw_costel WHERE iobjnm =
        '0COSTELMNT'.

          CLEAR lv_parentid.
          lv_parentid        = lw_costel-parentid.
          lw_final-costelmnt = lw_costel-nodename.


          DO.
            READ TABLE lt_costel1 INTO lw_costel1 WITH KEY nodeid =
            lv_parentid.

 

            CASE lw_costel1-tlevel.

 

              WHEN '06'.
                lw_final-lvl6_nodname      =
                lw_costel1-nodename.

              WHEN '07'.
                lw_final-lvl7_nodname      =
                lw_costel1-nodename.

 

            ENDCASE.

 

            CLEAR lv_parentid.


            IF lw_costel1-parentid IS NOT INITIAL.
              lv_parentid = lw_costel1-parentid.


            ELSE.
              EXIT.


            ENDIF.
          ENDDO.

 

          APPEND lw_final TO lt_final.
          CLEAR: lw_final.
        ENDLOOP.
      ENDIF.
    ENDIF.


    LOOP AT RESULT_PACKAGE ASSIGNING <result_fields>.

      READ TABLE lt_final INTO lw_final
      WITH KEY costelmnt = <result_fields>-costelmnt.

 

      <result_fields>-CO_AREA = <result_fields>-CO_AREA.
      <result_fields>-DATETO = <result_fields>-DATETO.
      <result_fields>-DATEFROM = <result_fields>-DATEFROM.
      <result_fields>-CSTELMNTYP = <result_fields>-CSTELMNTYP.
      <result_fields>-LOGSYS = <result_fields>-LOGSYS.
      <result_fields>-UNIT = <result_fields>-UNIT.
      <result_fields>-/BIC/ZCOST_REL =
      <result_fields>-/BIC/ZCOST_REL.
      <result_fields>-/bic/zlevel6 = lw_final-lvl6_nodname.
      <result_fields>-/bic/zlevel7 = lw_final-lvl7_nodname.

      APPEND <result_fields> TO RESULT_PACKAGE.
    ENDLOOP.


Viewing all articles
Browse latest Browse all 6437

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>