Summary

Aim of this document is to provide technical developers with some basic code and tool to traverse from Transaction Type to Schema(s), which have the type assigned. Then it lists a list of all Categories, for which it is valid.

Author(s):    Pavel Duchac

Company:    Fujitsu

Created on:  26/02/2015

/wp-content/uploads/2015/02/profile_image_display_653883.png

Author Bio

Pavel is a freelance CRM Consultant, currently working with Fujitsu Australia. He has worked on multiple SAP CRM implementations across Europe and Pacific region.

Background

Multilevel Categorization in SAP CRM for Service Requests is used to display and save hierarchy (of categories), which semantically refers to a certain aspect of business object or business process.

This allows us to capture the attributes in a systematic manner:

Untitled2.png

You can link schemas with applications either via Subject Profile or via combination of Transaction Type/Catalog Category.

Untitled.png

We needed to get all the schemas, which had a particular Transaction Type assigned. Then we needed to get all the categories for all the Schemas we were able to find.

SAP provides functionality which returns all the Application Areas assigned to particular Schema. You can use class CL_FSSC_RDS_CATEGO_DATA_PRO.

To retrieve the information in reverse is more difficult and there is no standard mean.

Following code shows one way how this can be achieved.


REPORT zucs_crm_cat_schema01.
* Structures
DATA: lv_object_ext_key TYPE crm_erms_cat_ob_extkey,
      ls_cate_data      TYPE fssc_rds_s_catego_category,
      es_schema_data    TYPE crmt_erms_cat_as_buf.
* Tables
DATA: lt_tab       TYPE TABLE OF crmc_erms_cat_sp,
      lt_guids     TYPE TABLE OF guid,
      lt_olink     TYPE crmt_erms_cat_ob_update_ttype,
      lt_link      TYPE crmt_erms_cat_ln_update_ttype,
      lt_cate_data TYPE fssc_rds_t_catego_category.
* Objects
DATA: gr_file_server   TYPE REF TO cl_fssc_rds_catego_file_srv,
      lr_schema        TYPE REF TO if_crm_erms_catego_aspect,
      mr_data_provider TYPE REF TO cl_fssc_rds_catego_data_pro.
FIELD-SYMBOLS <ls_guid> TYPE guid.
SELECTION-SCREEN BEGIN OF BLOCK one WITH FRAME TITLE text-001.
PARAMETERS: p_ptype TYPE crmt_process_type DEFAULT 'ZFIA'.
SELECTION-SCREEN END OF BLOCK one.
CREATE OBJECT gr_file_server.
* Get a subset of tx types / cat types and subj profiles
SELECT * FROM crmc_erms_cat_sp INTO TABLE lt_tab.
LOOP AT lt_tab ASSIGNING FIELD-SYMBOL(<ls_tab>).
  IF <ls_tab>-scheme_val(4) EQ p_ptype.
    APPEND INITIAL LINE TO lt_guids ASSIGNING <ls_guid>.
    MOVE <ls_tab>-scheme_guid TO <ls_guid>.
  ENDIF.
ENDLOOP.
DELETE ADJACENT DUPLICATES FROM lt_guids.
* Get Object IDs from OBJ_EXT_KEY
IF lt_guids IS NOT INITIAL.
  LOOP AT lt_guids INTO <ls_guid>.
    MOVE <ls_guid> TO lv_object_ext_key.
    CALL METHOD cl_crm_erms_cat_ob_db=>get_object_links
      EXPORTING
*       iv_object_guid            =
        iv_object_extkey          = lv_object_ext_key
      IMPORTING
        et_object_links           = lt_olink
*       es_object_link            =
      EXCEPTIONS
        object_link_not_found     = 1
        invalid_search_parameters = 2
        OTHERS                    = 3.
    IF sy-subrc <> 0.
*   Implement suitable error handling here
    ELSE.
*     Filter all ASP IDs by their status - we want active Categorization schemas only ('V')
      LOOP AT lt_olink ASSIGNING FIELD-SYMBOL(<ls_olink>).
        CALL METHOD cl_crm_erms_cat_ln_db=>get_category_links
          EXPORTING
            iv_obj_guid               = <ls_olink>-obj_guid
          IMPORTING
            et_link                   = lt_link
*           es_link                   =
*           et_obj                    =
          EXCEPTIONS
            invalid_search_parameters = 1
            OTHERS                    = 2.
        LOOP AT lt_link ASSIGNING FIELD-SYMBOL(<ls_link>).
*         Get CRM categorization schema data.
          CREATE OBJECT mr_data_provider
            EXPORTING
              iv_schema_guid = <ls_link>-cat_guid.
          lr_schema = mr_data_provider->get_schema_inst( ).
          IF lr_schema IS  BOUND.
            CALL METHOD mr_data_provider->get_schema_detail
              IMPORTING
                es_schema = es_schema_data.
            CHECK es_schema_data-asp-asp_state EQ 'V'. "Active Schema only
            CALL METHOD gr_file_server->prepare_data_for_export
              EXPORTING
                iv_schema_guid = es_schema_data-asp-asp_guid
                iv_with_attr   = 'X'
              IMPORTING
                et_cate_data   = lt_cate_data.
*           Result output
            WRITE: 'Categories:'.
            LOOP AT lt_cate_data ASSIGNING FIELD-SYMBOL(<ls_cate_data>).
              WRITE:/ <ls_cate_data>-cat_id.
            ENDLOOP.
          ENDIF.
        ENDLOOP.
      ENDLOOP.
    ENDIF.
  ENDLOOP.
ENDIF.
To report this post you need to login first.

2 Comments

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

  1. Thomas Konter

    Extremely useful right now, I almost despaired finding an appropriate solution to get the required categories without knowing an order guid.

    Thank you very much! 🙂

    (0) 

Leave a Reply