Skip to Content

在CRM中,类别(category)是比较复杂的,拥有不同的版本(aspect)来进行配置和管理。

下面展示了如何在代码中获取一个Order下面的所有已建的CAT_ID/CAT_GUID/CAT_Description

QQ20151010-0@2x.png

    “获取抬头类别CAT

    TYPES: ty_categories_tab_type TYPE TABLE OF  REF TO if_crm_erms_catego_category.

    DATA: lr_aspect   TYPE REF TO if_crm_erms_catego_aspect,

          lr_category TYPE REF TO if_crm_erms_catego_category.

    DATA: lv_line TYPE i.

    DATA: lr_categories TYPE REF TO data.

    FIELD-SYMBOLS: <fs_categories> TYPE ty_categories_tab_type.

    DATA: lw_cat_lang       TYPE crmt_erms_cat_ca_lang,

          lw_cat_lang_first TYPE crmt_erms_cat_ca_lang.

    DATA: lv_cat_string TYPE string.

    CREATE DATA lr_categories TYPE ty_categories_tab_type.

    CALL METHOD cl_crm_ml_category_util=>get_categoryfirst  “获取最底层的CAT

      EXPORTING

        iv_ref_guid = lv_guid

        iv_ref_kind = ‘A’

      IMPORTING

        er_aspect   = lr_aspect

        er_category = lr_category.

*

*

    IF lr_aspect IS BOUND.

      CALL METHOD lr_category->get_details

        IMPORTING

          ev_cat_lang = lw_cat_lang_first.   “获取最底层的CAT ID

*

      CALL METHOD cl_crm_ml_category_util=>get_cat_pars_all

        EXPORTING

          ir_aspect     = lr_aspect

          ir_category   = lr_category

        IMPORTING

          er_categories = lr_categories.

      ASSIGN lr_categories->* TO <fs_categories>.

      LOOP AT <fs_categories> INTO lr_category.

        CALL METHOD lr_category->get_details

          IMPORTING

            ev_cat_lang = lw_cat_lang.

        lw_cat_descdesc = lw_cat_langcatcat_id.        “获取其他层级的CAT ID

        INSERT lw_cat_desc INTO TABLE lt_cat_desc.

        CLEAR: lw_cat_desc, lw_cat_lang.

      ENDLOOP.

      lv_line = lines( lt_cat_desc ).

      CASE lv_line.

        WHEN 3.

          lw_order_headcat04 = lw_cat_lang_firstcatcat_id.

          READ TABLE lt_cat_desc INTO lw_cat_desc INDEX 1.

          lw_order_headcat03 = lw_cat_descdesc.

          CLEAR lw_cat_desc.

          READ TABLE lt_cat_desc INTO lw_cat_desc INDEX 2.

          lw_order_headcat02 = lw_cat_descdesc.

          CLEAR lw_cat_desc.

          READ TABLE lt_cat_desc INTO lw_cat_desc INDEX 3.

          lw_order_headcat01 = lw_cat_descdesc.

          CLEAR lw_cat_desc.

        WHEN 2.

          lw_order_headcat03 = lw_cat_lang_firstcatcat_id.

          READ TABLE lt_cat_desc INTO lw_cat_desc INDEX 1.

          lw_order_headcat02 = lw_cat_descdesc.

          CLEAR lw_cat_desc.

          READ TABLE lt_cat_desc INTO lw_cat_desc INDEX 2.

          lw_order_headcat01 = lw_cat_descdesc.

          CLEAR lw_cat_desc.

        WHEN 1.

          lw_order_headcat02 = lw_cat_lang_firstcatcat_id.

          READ TABLE lt_cat_desc INTO lw_cat_desc INDEX 1.

          lw_order_headcat01 = lw_cat_descdesc.

          CLEAR lw_cat_desc.

        WHEN 0.

          lw_order_headcat01 = lw_cat_lang_firstcatcat_id.

      ENDCASE.

      CLEAR lt_cat_desc.

      FREE: lr_aspect, lr_category, lr_categories.

    ENDIF.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply