BPC Hierarchy

Posted ckstock

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了BPC Hierarchy相关的知识,希望对你有一定的参考价值。

class ZBPC_PCD_GET definition
  public
  final
  create public .

public section.

  constants CON_BJZF type CHAR32 value BJZFBCSYB ##NO_TEXT.
  constants CON_TJZF type CHAR32 value TJZF ##NO_TEXT.
  constants CON_BJINP type CHAR32 value BJ.INP ##NO_TEXT.
  constants CON_Z_MISC1 type CHAR32 value MSC1_CG ##NO_TEXT.
  constants CON_Z_MISC1_YY type CHAR32 value MSC1_YY ##NO_TEXT.
  constants CON_Z_CATEGORY type CHAR32 value BUDGET_V0 ##NO_TEXT.
  constants CON_BCSYBINP type CHAR32 value BCSYB.INP ##NO_TEXT.
  constants CON_YGSYBINP type CHAR32 value YGSYB.INP ##NO_TEXT.

  methods GET_BPC_DATA
    importing
      !I_ROUTE type CHAR2
      !I_ACCOUNT type CHAR32
      !I_APPSET_ID type UJ_APPSET_ID
      !I_APPL_ID type UJ_APPL_ID
      !I_YEAR_INP type CHAR32 optional
      !I_NEXT_YEAR_INP type CHAR32 optional
      !I_YEAR type FLAG optional
      !I_SMON type FLAG optional
      !IT_PLANNING type ZBPC_S_PLANNING
    exporting
      !OT_SPLIT_GOAL type ZBPC_TT_PLANNING_SUB
      !OT_SPLIT_ZB type ZBPC_TT_PLANNING_SUB
      !OT_GROW_R type ZBPC_TT_GROW_R
      !OT_CG type ZBPC_TT_PLANNING_SUB
      !OT_ACTUAL type ZBPC_TT_ACTUAL
      !OT_GROW_E type ZBPC_TT_GROW_E
      !OT_ADJUST type ZBPC_TT_PLANNING_SUB
      !OT_SPLIT_RESULT type ZBPC_TT_PLANNING_SUB
      !OT_SMON_REAL_ACTUAL type ZBPC_TT_ACTUAL
      !OT_SS_RESULT type ZBPC_TT_ACTUAL .
  methods GET_ZRH_STRUC
    importing
      !I_CG type FLAG optional
      !I_YY type FLAG optional
    exporting
      !OT_TABLE_DOWN type ZBPCS_ORG_IN .
  methods GET_YT_MD
    importing
      !I_BJ type FLAG optional
      !I_TJ type FLAG optional
    exporting
      !OT_TABLE_DOWN type ZBPCS_ORG_IN .
  methods GET_PRODUCT_HIERARCHY
    exporting
      !OT_BK type ZBPC_TT_PROD_E
      !OT_SZB type ZBPC_TT_PROD_E
      !OT_BL_ID type ZBPC_TT_PROD_E
      !OT_UK type ZBPC_TT_PROD_E
      !OT_MC type ZBPC_TT_PROD_E
    changing
      !CT_HIERARCHY type STANDARD TABLE optional .
protected section.
private section.
ENDCLASS.



CLASS ZBPC_PCD_GET IMPLEMENTATION.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZBPC_PCD_GET->GET_BPC_DATA
* +-------------------------------------------------------------------------------------------------+
* | [--->] I_ROUTE                        TYPE        CHAR2
* | [--->] I_ACCOUNT                      TYPE        CHAR32
* | [--->] I_APPSET_ID                    TYPE        UJ_APPSET_ID
* | [--->] I_APPL_ID                      TYPE        UJ_APPL_ID
* | [--->] I_YEAR_INP                     TYPE        CHAR32(optional)
* | [--->] I_NEXT_YEAR_INP                TYPE        CHAR32(optional)
* | [--->] I_YEAR                         TYPE        FLAG(optional)
* | [--->] I_SMON                         TYPE        FLAG(optional)
* | [--->] IT_PLANNING                    TYPE        ZBPC_S_PLANNING
* | [<---] OT_SPLIT_GOAL                  TYPE        ZBPC_TT_PLANNING_SUB
* | [<---] OT_SPLIT_ZB                    TYPE        ZBPC_TT_PLANNING_SUB
* | [<---] OT_GROW_R                      TYPE        ZBPC_TT_GROW_R
* | [<---] OT_CG                          TYPE        ZBPC_TT_PLANNING_SUB
* | [<---] OT_ACTUAL                      TYPE        ZBPC_TT_ACTUAL
* | [<---] OT_GROW_E                      TYPE        ZBPC_TT_GROW_E
* | [<---] OT_ADJUST                      TYPE        ZBPC_TT_PLANNING_SUB
* | [<---] OT_SPLIT_RESULT                TYPE        ZBPC_TT_PLANNING_SUB
* | [<---] OT_SMON_REAL_ACTUAL            TYPE        ZBPC_TT_ACTUAL
* | [<---] OT_SS_RESULT                   TYPE        ZBPC_TT_ACTUAL
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD get_bpc_data.
    DATA:lt_sel TYPE uj0_t_sel,
         ls_sel TYPE uj0_s_sel.
    DATA:ls_cg TYPE  zbpc_s_planning_sub,
         lt_cg TYPE TABLE OF zbpc_s_planning_sub.
    DATA in_table_entity TYPE TABLE OF zbpc_s_entity.
    DATA in_table_product TYPE TABLE OF zbpc_s_product.
    DATA in_table_time TYPE TABLE OF zbpc_s_time.

    DATA:os_actual TYPE zbpc_s_planning_sub.
    DATA:OS_SS_RESULT TYPE zbpc_s_planning_sub.
    DATA:os_smon_real_actual TYPE zbpc_s_planning_sub.
    DATA:os_actual_smon TYPE zbpc_s_planning_sub.
    DATA:os_grow_r TYPE zbpc_s_planning_sub.
    DATA:os_grow_e TYPE zbpc_s_planning_sub.
    DATA:os_adjust TYPE zbpc_s_planning_sub.
    DATA:os_split_result TYPE zbpc_s_planning_sub.
    DATA:os_split_zb TYPE zbpc_s_planning_sub.
    DATA:os_split_goal TYPE zbpc_s_planning_sub.
    TYPES:BEGIN OF ty_total,
            z_entity  TYPE c LENGTH 32,
            z_product TYPE c LENGTH 32,
            signdata  TYPE /b28/oisdata,
          END OF ty_total.
    DATA:gt_total TYPE TABLE OF ty_total,
         gs_total TYPE  ty_total.

    CLEAR:os_actual,os_actual_smon,os_grow_r,os_grow_e,os_adjust,os_split_result,os_split_zb,os_split_goal,os_smon_real_actual,OS_SS_RESULT.
    REFRESH: ot_actual[],ot_grow_r[],ot_grow_e[],ot_adjust[],ot_split_result[],ot_split_zb[],ot_split_goal[],ot_cg[],ot_smon_real_actual[],OT_SS_RESULT[].
*    ot_actual_smon[],
    DEFINE sel.
      CLEAR ls_sel.
      ls_sel-dimension = &1.
      ls_sel-attribute = ID.
      ls_sel-sign = I.
      ls_sel-option = BT.
      ls_sel-low = &2.
      ls_sel-high = &3.
      APPEND ls_sel TO lt_sel.
    END-OF-DEFINITION.

    APPEND LINES OF it_planning-z_entity_s TO in_table_entity.
    APPEND LINES OF it_planning-z_product_s TO in_table_product.
    APPEND LINES OF it_planning-z_time_s TO in_table_time.
    CLEAR lt_sel.
    CLEAR:lt_cg[],lt_cg.
    sel   Z_ACCOUNT       i_account              i_account.                   "PCD科目
*    sel   ‘Z_CATEGORY‘      ‘BUDGET_V0‘         ‘BUDGET_V0‘.              "预算数
    sel   Z_CLASS         CLASS_NONE        CLASS_NONE.
    sel   Z_CURRENCY      CURRENCY_NONE     CURRENCY_NONE.
*    sel   ‘Z_DATASOURCE‘    ‘CF_RATE‘         ‘CF_RATE‘.
    SORT in_table_entity BY z_entity.
    DELETE ADJACENT DUPLICATES FROM in_table_entity COMPARING z_entity.
    LOOP AT in_table_entity INTO DATA(is_table_entity).
      sel   Z_ENTITY       is_table_entity-z_entity      is_table_entity-z_entity      .
    ENDLOOP.
    sel   Z_LINE          LINE_NONE         LINE_NONE.
*    sel   ‘Z_MISC1‘          I_z_misc1_yy          I_z_misc1_yy.
    sel   Z_MISC2         MISC2_NONE        MISC2_NONE.
    SORT in_table_product BY z_product.
    DELETE ADJACENT DUPLICATES FROM in_table_product COMPARING z_product.
    LOOP AT in_table_product  INTO DATA(is_table_product).
      sel   Z_PRODUCT is_table_product-z_product      is_table_product-z_product      .         .
    ENDLOOP.

    LOOP AT in_table_time  INTO DATA(is_table_time).
*      IF is_table_time-z_time = i_next_year_inp+0(4) && |.INP|.
*        is_table_time-z_time =  i_next_year_inp+0(4) && |.TOTAL|.
*      ENDIF.
      sel   Z_TIME           is_table_time-z_time             is_table_time-z_time  .              "时间
    ENDLOOP.
    sel   Z_VIEW          VIEW_NONE          VIEW_NONE.

    CALL FUNCTION ZBPC_GET_DATA
      EXPORTING
        i_appset  = i_appset_id
        i_appl_id = i_appl_id
        it_range  = lt_sel
      TABLES
        et_data   = lt_cg.
    APPEND LINES OF lt_cg TO  ot_cg .



    DATA:lv_goal_result TYPE  /b28/oisdata.
    TYPES:BEGIN OF ty_planning,
            z_product    TYPE c LENGTH 32,
            z_time       TYPE c LENGTH 32,
            measure      TYPE c LENGTH 32,
            z_account    TYPE c LENGTH 32,
            z_category   TYPE c LENGTH 32,
            z_class      TYPE c LENGTH 32,
            z_currency   TYPE c LENGTH 32,
            z_datasource TYPE c LENGTH 32,
            z_entity     TYPE c LENGTH 32,
            z_line       TYPE c LENGTH 32,
            z_misc1      TYPE c LENGTH 32,
            z_misc2      TYPE c LENGTH 32,
            z_view       TYPE c LENGTH 32,
            signeddata   TYPE /b28/oisdata,
          END OF ty_planning.
    DATA:i_z_misc1(32).
    IF i_route = |CG|.
      i_z_misc1 = con_z_misc1.
    ELSEIF i_route = |BL|."取拆分比例
      i_z_misc1 = |MISC1_NONE|.
    ELSEIF i_route = |YY|.
      i_z_misc1 = con_z_misc1_yy.
    ENDIF.

    IF i_smon IS NOT INITIAL.
      DATA:lv_total TYPE /b28/oisdata.
      CLEAR:lv_total.
      LOOP AT lt_cg  INTO ls_cg  .
        IF  i_route = |BL|."取拆分比例.
          IF ls_cg-z_category = con_z_category AND ls_cg-z_datasource = |CF_RATE| AND ls_cg-z_misc1 = i_z_misc1.
            os_actual = CORRESPONDING #( ls_cg )."
            APPEND os_actual TO ot_actual.
            CLEAR os_actual.
          ENDIF.
        ELSE.

          IF ls_cg-z_category = con_z_category AND ls_cg-z_datasource = |ZZ_RESULT| AND ls_cg-z_misc1 = i_z_misc1.
*          AND ls_cg-z_time+0(4) = i_next_year_inp+0(4).
            os_actual = CORRESPONDING #( ls_cg )."
            APPEND os_actual TO ot_actual.
            CLEAR os_actual.
          ENDIF.


          IF ls_cg-z_category = con_z_category AND ls_cg-z_datasource = |SS_RESULT| AND ls_cg-z_misc1 = i_z_misc1.
*          AND ls_cg-z_time+0(4) = i_next_year_inp+0(4).
            OS_SS_RESULT = CORRESPONDING #( ls_cg )."赞返-板块-货架组-月(含调整) 尽在此用
            APPEND OS_SS_RESULT TO OT_SS_RESULT.
            CLEAR OS_SS_RESULT.
          ENDIF.

*真正月实际数
          IF ls_cg-z_category = |ACT&FCS| AND ls_cg-z_datasource = |FINAL| AND ls_cg-z_misc1 = |MISC1_NONE|
               AND ls_cg-z_time = i_year_inp.
            os_smon_real_actual = CORRESPONDING #( ls_cg )."
            APPEND os_smon_real_actual TO ot_smon_real_actual.
            CLEAR os_smon_real_actual.
          ENDIF.


          IF ls_cg-z_category = con_z_category AND ls_cg-z_datasource = |MO_DATA| AND ls_cg-z_misc1 = i_z_misc1.
*             AND ls_cg-z_time = i_next_year_inp.
            os_adjust = CORRESPONDING #( ls_cg ).
            APPEND os_adjust TO ot_adjust.
            CLEAR os_adjust.
          ENDIF.

        ENDIF.
      ENDLOOP.
    ENDIF.

    IF i_year IS NOT INITIAL.
      LOOP AT lt_cg  INTO ls_cg  .
***各部类本年度实际数
        IF ls_cg-z_category = |ACT&FCS| AND ls_cg-z_datasource = |FINAL| AND ls_cg-z_misc1 = |MISC1_NONE|
          AND ls_cg-z_time = i_year_inp.
          os_actual = CORRESPONDING #( ls_cg )."
          APPEND os_actual TO ot_actual.
          CLEAR os_actual.

        ENDIF.
*-------试算版
***增长率
        IF ls_cg-z_category = con_z_category AND ls_cg-z_datasource = |IN_RATE| AND ls_cg-z_misc1 = i_z_misc1
          AND ls_cg-z_time = i_next_year_inp.
          os_grow_r = CORRESPONDING #( ls_cg )."
          APPEND os_grow_r TO ot_grow_r.
          CLEAR os_grow_r.
        ENDIF.
***增长额
        IF ls_cg-z_category = con_z_category AND ls_cg-z_datasource = |IN_DATA| AND ls_cg-z_misc1 = i_z_misc1
           AND ls_cg-z_time = i_next_year_inp.
          os_grow_e = CORRESPONDING #( ls_cg ).
          APPEND os_grow_e TO ot_grow_e.
          CLEAR os_grow_e.
        ENDIF.
***下年调整值
        IF ls_cg-z_category = con_z_category AND ls_cg-z_datasource = |MO_DATA| AND ls_cg-z_misc1 = i_z_misc1
           AND ls_cg-z_time = i_next_year_inp.
          os_adjust = CORRESPONDING #( ls_cg ).
          APPEND os_adjust TO ot_adjust.
          CLEAR os_adjust.
        ENDIF.
      ENDLOOP.
*-------试算版 结果输出
      CLEAR:lv_goal_result.
      LOOP AT ot_actual INTO os_actual.
        os_split_result = CORRESPONDING #( os_actual ).
        os_split_result-z_datasource =   |SS_RESULT|.
        os_split_result-z_misc1 =   i_z_misc1.
        os_split_result-z_category =   con_z_category. "BUDGET_V0
        os_split_result-z_time =   i_next_year_inp.

        READ TABLE ot_grow_r INTO os_grow_r WITH KEY z_entity = os_actual-z_entity
                                                     z_product = os_actual-z_product .
        IF sy-subrc = 0.
          os_split_result-signeddata = os_actual-signeddata  * ( 1 + os_grow_r-signeddata ).
        ENDIF.

        READ TABLE ot_grow_e INTO os_grow_e WITH KEY z_entity = os_actual-z_entity
                                                     z_product = os_actual-z_product .
        IF sy-subrc = 0.
          os_split_result-signeddata = os_grow_e-signeddata +  os_split_result-signeddata. "加上额度
        ENDIF.

        lv_goal_result  = lv_goal_result + os_split_result-signeddata.
        APPEND os_split_result TO ot_split_result.
        CLEAR os_split_result.
      ENDLOOP.
*-------目标分解
***占比

      LOOP AT ot_split_result ASSIGNING FIELD-SYMBOL(<fs_res>).
        os_split_zb = CORRESPONDING #( <fs_res> ).
        os_split_zb-z_datasource = |ZZ_ZB|.
        IF lv_goal_result NE 0.
          os_split_zb-signeddata = <fs_res>-signeddata / lv_goal_result.
        ENDIF.
        APPEND os_split_zb TO ot_split_zb.
        CLEAR:os_split_zb.
      ENDLOOP.
***目标
*    LOOP AT Ot_SPLIT_ZB INTO Os_SPLIT_ZB.
*      Os_SPLIT_GOAL = CORRESPONDING #( Os_SPLIT_ZB ).
**      DATA(lv_signeddata) = VALUE #( it_bl_bj_year_sum[ 1 ]-signeddata OPTIONAL ).
**      DATA(lv_signeddata) = lv_uk_bj_sum.
*      Os_SPLIT_GOAL-signeddata = Os_SPLIT_ZB-signeddata *  lv_signeddata.
*      Os_SPLIT_GOAL-z_datasource =   |ALLO|.
*      Os_SPLIT_GOAL-z_misc1 =  I_z_misc1.
*      APPEND Os_SPLIT_GOAL TO Ot_SPLIT_GOAL.
*      CLEAR: Os_SPLIT_GOAL .
*    ENDLOOP.

****结果
*    LOOP AT it_goal_spli ASSIGNING FIELD-SYMBOL(<fs_goal>).
*      is_ny_sub_res = CORRESPONDING #( <fs_goal> ).
*      is_ny_sub_res-z_datasource =   |ZZ_RESULT|.
*      is_ny_sub_res-z_misc1 =   |MSC1_CG|.
*      is_ny_sub_res-z_category =   |BUDGET_V0|.
**      is_ny_sub_res-z_time =   lv_next_year.
*      READ TABLE it_ny_sub_adjust INTO is_ny_sub_adjust WITH KEY       z_entity = <fs_goal>-z_entity
*                                                                         z_product = <fs_goal>-z_product .
*      IF sy-subrc = 0.
*        is_ny_sub_res-signeddata  =  <fs_goal>-signeddata + is_ny_sub_adjust-signeddata.  "结果  =  目标 + 调整
*      ENDIF.
*      APPEND is_ny_sub_res TO it_ny_sub_res.
*      CLEAR is_ny_sub_res.
*    ENDLOOP.
****增长率
*    LOOP AT it_ny_sub_res  ASSIGNING FIELD-SYMBOL(<fs_ny_bj_res>).
*      is_ny_bj_rate = CORRESPONDING #( <fs_ny_bj_res> ).
*      is_ny_bj_rate-z_datasource =   |ZZ_RATE|.
*      is_ny_bj_rate-z_misc1 =   |MSC1_CG|.
*      is_ny_bj_rate-z_category =   |BUDGET_V0|.
**      is_ny_sub_rate-z_time =   |2020.INP|.
*      READ TABLE it_year_sub_actual INTO is_year_sub_actual WITH KEY       z_entity = <fs_ny_bj_res>-z_entity
*                                                                     z_product = <fs_ny_bj_res>-z_product .
*      IF sy-subrc = 0.
*        is_ny_bj_rate-signeddata = ( <fs_ny_bj_res>-signeddata - is_year_sub_actual-signeddata ) / is_year_sub_actual-signeddata.
*      ENDIF.
*      APPEND is_ny_bj_rate TO it_ny_bj_rate.
*      CLEAR is_ny_bj_rate.
*    ENDLOOP.
*    APPEND LINES OF lt_cg to  ot_cg-ZBPC_DATA.
*    ot_cg[] = lt_cg[].
    ENDIF.
  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZBPC_PCD_GET->GET_PRODUCT_HIERARCHY
* +-------------------------------------------------------------------------------------------------+
* | [<---] OT_BK                          TYPE        ZBPC_TT_PROD_E
* | [<---] OT_SZB                         TYPE        ZBPC_TT_PROD_E
* | [<---] OT_BL_ID                       TYPE        ZBPC_TT_PROD_E
* | [<---] OT_UK                          TYPE        ZBPC_TT_PROD_E
* | [<---] OT_MC                          TYPE        ZBPC_TT_PROD_E
* | [<-->] CT_HIERARCHY                   TYPE        STANDARD TABLE(optional)
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD get_product_hierarchy.
*"----------------------------------------------------------------------
* 获取层级关系
    DATA ot_table_down TYPE zbpcs_org_in.
    DATA ot_table_res TYPE   TABLE OF  /b28/hcsdsmyt.
    DATA:gt_bk TYPE SORTED TABLE OF /b28/hcsdsmyt WITH NON-UNIQUE KEY parentid.
    DATA:gs_bk1 TYPE   /b28/hcsdsmyt.
    DATA:gt_szb TYPE SORTED TABLE OF /b28/hcsdsmyt WITH NON-UNIQUE KEY parentid.
    DATA:gs_szb TYPE   /b28/hcsdsmyt. "生杂百
    DATA:gt_bl_id TYPE SORTED TABLE OF /b28/hcsdsmyt WITH NON-UNIQUE KEY parentid.
    DATA:gs_bl_id TYPE   /b28/hcsdsmyt.
    DATA:gt_hierarchy_uk TYPE SORTED TABLE OF /b28/hcsdsmyt WITH NON-UNIQUE KEY parentid.
    DATA:gs_hierarchy_uk TYPE   /b28/hcsdsmyt.
    DATA:gt_hierarchy_mc TYPE SORTED TABLE OF /b28/hcsdsmyt WITH NON-UNIQUE KEY parentid.
    DATA:gs_hierarchy_mc TYPE   /b28/hcsdsmyt.
*"----------------------------------------------------------------------
    TYPES: BEGIN OF ty_tag_line,
             flag_uk_to_mc    TYPE i,
             flag_bl_to_uk    TYPE i,

             flag_szb_merge   TYPE i,
             flag_bk_merge    TYPE i,
             flag_bl_merge    TYPE i,
             zbl_inp          TYPE  rsshnodenamestr, "部类
             z_hierarchy_uk   TYPE rsshnodenamestr, "UK.
             z_product_mc     TYPE rsshnodenamestr, "MC.
             z_product_bl     TYPE rsshnodenamestr, "部类.
             z_product_bk     TYPE rsshnodenamestr, "板块.
             z_product_szb    TYPE rsshnodenamestr, "板块.

             z_hierarchy_prod TYPE rsshnodenamestr,
             hieid            TYPE rshieid,
             objvers          TYPE rsobjvers,
             nodeid           TYPE rshienodid,
             iobjnm           TYPE rsiobjnm,
             nodename         TYPE  rsshnodenamestr,
             none_inp         TYPE  rsshnodenamestr,

             tlevel           TYPE  rstlevel,
             link             TYPE rslink,
             parentid         TYPE rsparent,
             childid          TYPE rschild,
             nextid           TYPE rsnext,
             sum_mc_to_uk     TYPE i,
             sum_uk_to_bl     TYPE i,
           END OF ty_tag_line.
    DATA lt_hierarchy TYPE STANDARD TABLE OF ty_tag_line  .
    DATA ls_hierarchy TYPE  ty_tag_line  .
    DATA:lv_chain_uk_to_mc TYPE i."MC合单
    DATA:lv_chain_bl_to_uk TYPE i."UK合单
    DATA:lv_chain_bk_to_bl TYPE i."部类合单
    DATA:lv_bk_to_szb TYPE i."生杂百合单
    DATA:lv_szb_to_bl TYPE i."部类合单
*"----------------------------------------------------------------------
    REFRESH:lt_hierarchy[],ot_table_down-zhierarchy[],ot_table_res[],ot_table_down-ZHIERARCHY[],gt_bk[],gt_szb[],gt_bl_id[],gt_hierarchy_uk[],gt_hierarchy_mc[].
    CLEAR:lv_bk_to_szb,lv_szb_to_bl,lv_chain_bl_to_uk,lv_chain_uk_to_mc.
    DATA(lo_bpc) = NEW zbpc_pcd_get( ).
    lo_bpc->get_zrh_struc( EXPORTING i_cg  =  |X|   IMPORTING ot_table_down = ot_table_down ).
    APPEND LINES OF ot_table_down-zhierarchy TO ot_table_res.

    LOOP AT ot_table_res ASSIGNING FIELD-SYMBOL(<fs_org>).
      CASE <fs_org>-tlevel.
        WHEN 01.
          gs_bk1 = CORRESPONDING #( <fs_org> )."板块ID .
          APPEND gs_bk1 TO gt_bk.CLEAR gs_bk1.
        WHEN 02.
          gs_szb = CORRESPONDING #( <fs_org> )."生杂百 .
          APPEND gs_szb TO gt_szb.CLEAR gs_szb.
        WHEN 03.
          gs_bl_id = CORRESPONDING #( <fs_org> )."部类ID .
          APPEND gs_bl_id TO gt_bl_id.CLEAR gs_bl_id.
        WHEN 04.
          gs_hierarchy_uk = CORRESPONDING #( <fs_org> )."UK .
          APPEND gs_hierarchy_uk TO gt_hierarchy_uk.CLEAR gs_hierarchy_uk.
        WHEN 05.
          gs_hierarchy_mc = CORRESPONDING #( <fs_org> )."MC .
          APPEND gs_hierarchy_mc TO gt_hierarchy_mc.CLEAR gs_hierarchy_mc.
        WHEN OTHERS.
      ENDCASE.
    ENDLOOP.

    LOOP AT gt_bk INTO gs_bk1.
      lv_bk_to_szb = lv_bk_to_szb + 1.
      LOOP AT gt_szb INTO gs_szb WHERE parentid = gs_bk1-nodeid..
        lv_szb_to_bl = lv_szb_to_bl + 1.

        LOOP AT gt_bl_id INTO DATA(gs_01) WHERE  parentid = gs_szb-nodeid..

          lv_chain_bl_to_uk = lv_chain_bl_to_uk + 1."部类下的uk.
          LOOP AT gt_hierarchy_uk INTO DATA(gs_02) WHERE  parentid = gs_01-nodeid.
            lv_chain_uk_to_mc = lv_chain_uk_to_mc + 1. "uk下的MC.
            LOOP AT gt_hierarchy_mc INTO DATA(gs_03) WHERE parentid = gs_02-nodeid..

              ls_hierarchy  = CORRESPONDING #( gs_03 ).
              ls_hierarchy-z_product_szb = gs_szb-nodename .  "SZB.
              ls_hierarchy-z_product_mc = gs_03-nodename .  "MC.
              ls_hierarchy-z_product_bk = gs_bk1-nodename   .  "板块.
              ls_hierarchy-none_inp = gs_01-nodename+0(8).  ""部类 去掉inp.
              ls_hierarchy-zbl_inp = gs_01-nodename  .  ""部类  inp.
              ls_hierarchy-z_hierarchy_uk = gs_02-nodename.  "uk.
              ls_hierarchy-flag_uk_to_mc = lv_chain_uk_to_mc ."MC合单(标记处MC属于哪些UK)
              ls_hierarchy-flag_bl_to_uk = lv_chain_bl_to_uk ."UK合单(标记处UK属于哪些部类)
              ls_hierarchy-flag_bl_merge = lv_szb_to_bl ."部类合单 (标记部类属于哪些生杂百)
              ls_hierarchy-flag_szb_merge = lv_bk_to_szb ."生杂百合单

              APPEND ls_hierarchy TO lt_hierarchy.
              CLEAR ls_hierarchy.
            ENDLOOP.

          ENDLOOP.

        ENDLOOP.


      ENDLOOP.

    ENDLOOP.

    APPEND LINES OF lt_hierarchy TO ct_hierarchy.
    OT_BK[] = gt_bk[].
    OT_SZB[] = gt_szb[].
    OT_BL_ID[] = gt_bl_id[].
    OT_UK[] = gt_hierarchy_uk[].
    OT_MC[] = gt_hierarchy_mc[].

  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZBPC_PCD_GET->GET_YT_MD
* +-------------------------------------------------------------------------------------------------+
* | [--->] I_BJ                           TYPE        FLAG(optional)
* | [--->] I_TJ                           TYPE        FLAG(optional)
* | [<---] OT_TABLE_DOWN                  TYPE        ZBPCS_ORG_IN
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD get_yt_md.
    DATA:it_table_midd TYPE TABLE OF /b28/hcsdy6jc   .
    DATA:is_table_midd TYPE   /b28/hcsdy6jc .
    DATA:lv_nodename TYPE  /b28/hcsdy6jc-nodename.
*    IF i_bj IS NOT INITIAL.
*      lv_nodename =  ‘BCSYBYYBJ‘.
*    ELSEIF i_tj IS NOT INITIAL.
*      lv_nodename =  ‘BCSYBYYTJ‘.
*    ENDIF.

     SELECT * INTO TABLE @DATA(gt_yt)
       FROM /b28/hcsdy6jc
       WHERE parentid =  00000221.

IF gt_yt[] is not INITIAL.
    SELECT * INTO CORRESPONDING FIELDS OF TABLE    @it_table_midd
      FROM /b28/hcsdy6jc
      FOR ALL ENTRIES IN @gt_yt
      WHERE nodename = @gt_yt-nodename.
ENDIF.

    "
    IF it_table_midd[] IS NOT INITIAL.
      SELECT * INTO  TABLE @DATA(gt_table1)
        FROM /b28/hcsdy6jc
        FOR ALL ENTRIES IN   @it_table_midd
        WHERE parentid =  @it_table_midd-nodeid. "


      IF gt_table1[] IS NOT INITIAL..
        SELECT * INTO  TABLE @DATA(gt_table2)
          FROM /b28/hcsdy6jc
          FOR ALL ENTRIES IN   @gt_table1[]
          WHERE parentid =  @gt_table1-nodeid . "


        IF gt_table2[] IS NOT INITIAL..
          SELECT * INTO  TABLE @DATA(gt_table3)
            FROM /b28/hcsdy6jc
            FOR ALL ENTRIES IN   @gt_table2[]
            WHERE parentid =  @gt_table2-nodeid. "


          IF gt_table3[] IS NOT INITIAL..
            SELECT * INTO  TABLE @DATA(gt_table4)
              FROM /b28/hcsdy6jc
              FOR ALL ENTRIES IN   @gt_table3[]
              WHERE parentid =  @gt_table3-nodeid. "


            IF gt_table4[] IS NOT INITIAL..
              SELECT * INTO  TABLE @DATA(gt_table5)
                FROM /b28/hcsdy6jc
                FOR ALL ENTRIES IN   @gt_table4[]
                WHERE parentid =  @gt_table4-nodeid. "


              IF gt_table5[] IS NOT INITIAL..
                SELECT * INTO  TABLE @DATA(gt_table6)
                  FROM /b28/hcsdy6jc
                  FOR ALL ENTRIES IN   @gt_table5[]
                  WHERE parentid =  @gt_table5-nodeid. "

              ENDIF.

            ENDIF.
          ENDIF.
        ENDIF.
      ENDIF.
    ENDIF.

    DELETE gt_table2 WHERE  childid NE |00000000|.
    DELETE gt_table3 WHERE  childid NE |00000000|.
    DELETE gt_table4 WHERE  childid NE |00000000|.
    DELETE gt_table5 WHERE  childid NE |00000000|.
    DELETE gt_table6 WHERE  childid NE |00000000|.

    APPEND LINES OF gt_table2 TO ot_table_down-zhierarchy .
    APPEND LINES OF gt_table3 TO ot_table_down-zhierarchy.
    APPEND LINES OF gt_table4 TO ot_table_down-zhierarchy.
    APPEND LINES OF gt_table5 TO ot_table_down-zhierarchy.
    APPEND LINES OF gt_table6 TO ot_table_down-zhierarchy.
  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZBPC_PCD_GET->GET_ZRH_STRUC
* +-------------------------------------------------------------------------------------------------+
* | [--->] I_CG                           TYPE        FLAG(optional)
* | [--->] I_YY                           TYPE        FLAG(optional)
* | [<---] OT_TABLE_DOWN                  TYPE        ZBPCS_ORG_IN
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD GET_ZRH_STRUC.
    DATA:it_table_midd TYPE TABLE OF /b28/hcsdsmyt   .
    DATA:is_table_midd TYPE   /b28/hcsdsmyt .
    DATA:it_table_midd_yt TYPE TABLE OF /b28/hcsdy6jc   .
    DATA:is_table_midd_yt TYPE   /b28/hcsdy6jc .
*  APPEND LINES OF in_table-zhierarchy TO it_table_midd.
    IF i_cg IS NOT INITIAL.

      SELECT * INTO CORRESPONDING FIELDS OF TABLE    it_table_midd
        FROM /b28/hcsdsmyt
        WHERE nodeid =  00000002
        AND tlevel =  01. "

      IF it_table_midd[] IS NOT INITIAL.
        APPEND LINES OF it_table_midd TO ot_table_down-zhierarchy.
        SELECT * INTO  TABLE @DATA(gt_table1)
          FROM /b28/hcsdsmyt
          FOR ALL ENTRIES IN   @it_table_midd
          WHERE parentid =  @it_table_midd-nodeid. "

        DELETE gt_table1 WHERE tlevel NE 02.
        APPEND LINES OF gt_table1 TO ot_table_down-zhierarchy.
        IF gt_table1[] IS NOT INITIAL..
          SELECT * INTO  TABLE @DATA(gt_table2)
            FROM /b28/hcsdsmyt
            FOR ALL ENTRIES IN   @gt_table1[]
            WHERE parentid =  @gt_table1-nodeid . "
          DELETE gt_table2 WHERE tlevel NE 03.
          APPEND LINES OF gt_table2 TO ot_table_down-zhierarchy.
        ENDIF.


        IF gt_table2[] IS NOT INITIAL..
          SELECT * INTO  TABLE @DATA(gt_table3)
            FROM /b28/hcsdsmyt
            FOR ALL ENTRIES IN   @gt_table2[]
            WHERE parentid =  @gt_table2-nodeid. "
          DELETE gt_table3 WHERE tlevel NE 04.
          APPEND LINES OF gt_table3 TO ot_table_down-zhierarchy..
        ENDIF.

        IF gt_table3[] IS NOT INITIAL..
          SELECT * INTO  TABLE @DATA(gt_table4)
            FROM /b28/hcsdsmyt
            FOR ALL ENTRIES IN   @gt_table3[]
            WHERE parentid =  @gt_table3-nodeid. "
          DELETE gt_table4 WHERE tlevel NE 05.
          APPEND LINES OF gt_table4 TO ot_table_down-zhierarchy..
        ENDIF.

        IF gt_table4[] IS NOT INITIAL..
          SELECT * INTO  TABLE @DATA(gt_table5)
            FROM /b28/hcsdsmyt
            FOR ALL ENTRIES IN   @gt_table4[]
            WHERE parentid =  @gt_table4-nodeid. "
          DELETE gt_table5 WHERE tlevel NE 06.
          APPEND LINES OF gt_table5 TO ot_table_down-zhierarchy..
        ENDIF.

      ENDIF.

      LOOP AT ot_table_down-zhierarchy ASSIGNING FIELD-SYMBOL(<fs>).
        IF <fs>-childid NE |00000000|.
          <fs>-nodename = <fs>-nodename && |.INP|.
        ENDIF.
      ENDLOOP.
    ENDIF.

*"----------------------------------------------------------------------
    IF i_yy IS NOT INITIAL.
      SELECT * INTO CORRESPONDING FIELDS OF TABLE    it_table_midd_yt
        FROM /b28/hcsdy6jc
        WHERE nodeid =  00000003
        AND tlevel =  01.

      IF it_table_midd_yt[] IS NOT INITIAL.
        APPEND LINES OF it_table_midd_yt TO ot_table_down-zhierarchy.
        SELECT * INTO  TABLE @DATA(gt_table_yt1)
           FROM /b28/hcsdy6jc
           FOR ALL ENTRIES IN   @it_table_midd_yt
           WHERE parentid =  @it_table_midd_yt-nodeid.

        DELETE gt_table_yt1 WHERE tlevel NE 02.
        DELETE gt_table_yt1 WHERE nodename NE YT.INP_TOTAL.
        APPEND LINES OF gt_table_yt1 TO ot_table_down-zhierarchy.
        IF gt_table_yt1[] IS NOT INITIAL..
          SELECT * INTO  TABLE @DATA(gt_tableyt2)
            FROM /b28/hcsdy6jc
            FOR ALL ENTRIES IN   @gt_table_yt1[]
            WHERE parentid =  @gt_table_yt1-nodeid . "
          DELETE gt_tableyt2 WHERE tlevel NE 03.
          APPEND LINES OF gt_tableyt2 TO ot_table_down-zhierarchy.
        ENDIF.

        IF gt_tableyt2[] IS NOT INITIAL..
          SELECT * INTO  TABLE @DATA(gt_tableyt3)
            FROM /b28/hcsdy6jc
            FOR ALL ENTRIES IN   @gt_tableyt2[]
            WHERE parentid =  @gt_tableyt2-nodeid. "
          DELETE gt_tableyt3 WHERE tlevel NE 04.
          APPEND LINES OF gt_tableyt3 TO ot_table_down-zhierarchy..
        ENDIF.

        IF gt_tableyt3[] IS NOT INITIAL..
          SELECT * INTO  TABLE @DATA(gt_tableyt4)
            FROM /b28/hcsdy6jc
            FOR ALL ENTRIES IN   @gt_tableyt3[]
            WHERE parentid =  @gt_tableyt3-nodeid. "
          DELETE gt_tableyt4 WHERE tlevel NE 04.
          APPEND LINES OF gt_tableyt4 TO ot_table_down-zhierarchy..
        ENDIF.

        IF gt_tableyt4[] IS NOT INITIAL..
          SELECT * INTO  TABLE @DATA(gt_tableyt5)
            FROM /b28/hcsdy6jc
            FOR ALL ENTRIES IN   @gt_tableyt4[]
            WHERE parentid =  @gt_tableyt4-nodeid. "
          DELETE gt_tableyt5 WHERE tlevel NE 04.
          APPEND LINES OF gt_tableyt5 TO ot_table_down-zhierarchy..
        ENDIF.



      ENDIF.
    ENDIF.
  ENDMETHOD.
ENDCLASS.

以上是关于BPC Hierarchy的主要内容,如果未能解决你的问题,请参考以下文章

text BPC BAdI实现UJ_CUSTOM_LOGIC

UGUI Image快速创建帧动画

sql 时区,(从https://pastebin.com/Bpc3eNk9偷来)

如何使用 vImageMatrixMultiply 将 YUV 平面数据转换为 32 bpp、8bpc RGBX?

小功能丨代码修改物体在 Hierarchy 上顺序

小功能丨代码修改物体在 Hierarchy 上顺序