cancel
Showing results for 
Search instead for 
Did you mean: 

bapi / api / function to get Multilevel Categorization chosen in Serv Order

Former Member
0 Kudos

Hello experts,

As CRM order only stores in table CRMD_SRV_SUBJECT the lowest level of the Multilevel Categorization chosen in the Service order. I wondered if somebody knows if there is a BAPI / API / Function that can retrieve the upper levels by passing the lowest one.

I mean, in a service order with 4 levels of categorization chosen:

Level1

Level 2

Level 3

Level 4

Only Level 4 is stored in the CRMD_SRV_SUBJECT for Service Orders. That is the reason why I need some BAPI or similiar to get the upper levels of the Service Order.

I hope you can help me!

Many thanks!

Pablo

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Pablo,

Similar type of requirement came to us in one of the project, we solved using custom code.

just copy and paste the method in your custom class

METHOD get_categories.

input parameter:- object_guid

export parameter:- zcrm_categories_t." ( cat_id, cat_desc,cat_guid )

*    Get category levels based on transaction guid

************************************

     DATA: lr_aspect    TYPE REF TO if_crm_erms_catego_aspect,

           lr_category  TYPE REF TO if_crm_erms_catego_category,

           lv_ref_guid  TYPE crmt_object_guid, ". 

           lv_asp_guid  TYPE crm_erms_cat_guid,

           lv_cat_guid  TYPE crm_erms_cat_guid,

           lv_sel_level TYPE int4,

           ls_cat       TYPE crmt_erms_cat_ca_buf,

           et_cat_tree  TYPE bsp_wd_dropdown_table,

           ls_cat_tree  TYPE bsp_wd_dropdown_line,

           lv_cat_id    TYPE crm_erms_cat_ca_id,

           ls_category  TYPE zcrm_categories,

           lt_category  TYPE zcrm_categories_t." ( cat_id, cat_desc,cat_guid )

     lv_ref_guid = iv_guid." guid of object id

     CALL METHOD cl_crm_ml_category_util=>get_categoryfirst

       EXPORTING

         iv_ref_guid     = lv_ref_guid

         iv_ref_kind     = 'A'" Header

         iv_catalog_type = 'D' "ORDER_READ->ET_SUBJECT->CAT_ID'

       IMPORTING

         er_aspect       = lr_aspect

         er_category     = lr_category.

* get aspect guid

     CALL METHOD lr_aspect->get_asp_guid

       RECEIVING

         rv_asp_guid = lv_asp_guid.

* get category guid

     CALL METHOD lr_category->get_details

       IMPORTING

         ev_cat = ls_cat.

     lv_cat_guid = ls_cat-cat_guid.

*get category levels

     cl_crm_ml_category_util=>get_selected_category_tree(

     EXPORTING

     iv_selected_cat_guid = lv_cat_guid    " Selected Category GUID

     iv_schema_guid       = lv_asp_guid    " Schema GUID

     IMPORTING

     et_cat_tree          = et_cat_tree " category levels

     ev_selected_level    = lv_sel_level  )" Selected Category Level

     CLEAR: lv_cat_guid.

     IF et_cat_tree IS NOT INITIAL." sy-subrc = 0.

       LOOP AT et_cat_tree INTO ls_cat_tree.

         IF ls_cat_tree IS NOT INITIAL.

           ls_category-cat_guid = ls_cat_tree-key.

           ls_category-cat_desc = ls_cat_tree-value.

           SELECT SINGLE cat_id INTO lv_cat_id FROM crmc_erms_cat_ca WHERE cat_guid = ls_category-cat_guid.

           ls_category-cat_id = lv_cat_id.

           APPEND ls_category TO lt_category.

           et_category = lt_category.

           CLEAR:ls_cat_tree,ls_category,lv_cat_id.

         ENDIF.

       ENDLOOP.

     ENDIF.

   ENDMETHOD.

former_member191572
Contributor
0 Kudos

Hi,

Please use the Utilities class CL_CRM_ML_Category_util and methodget_categories will provide the category details based on the header guid u r passing.

saumya_govil
Active Contributor
0 Kudos

Hi Pablo,

The higher level categorization information is stored in table CRMD_SRV_OSSET.

You can also use FM CRM_ORDER_READ to fetch this information easily.

Just check the output parameter ET_SUBJECT. This parameter stores the entire hierarchy of the categorization levels.

Hope this helps!

Regards,

Saumya

Former Member
0 Kudos

Hello Saumya, thanks for your reply!

But in that table I can only see the following fields: CLIENT GUID GUID_SET SUBJECT_PROFILE PROFILE_TYPE

I also opened a SAP OSS note and they told me that I should look for a Functon Module as SAP CRM does not store the upper levels in any table.

"Under package CRM_ERMS_CATEGORIZATION (TX SE80) you can found the

function modules"

Unfortunatelly, I was not able to find it. Any suggestion?

Best regards,

Pablo

saumya_govil
Active Contributor
0 Kudos

Hi Pablo,

The table CRMD_SRV_OSSET stores the subject profile that is linked to the trasnaction type.

This subject profile is linked to the categoies through table CRMD_SRV_SUBJECT.

The categories are store in table fields CODEGRUPPE and CODE.

You can retrieve this value by using FM CRM_ORDER_READ and checking the output parameter ET_SUBJECT.

ET_SUBJECT is a structure of type CRMT_SUBJECT_WRK which stores the category values in fields CODEGRUPPE and CODE. You can also retrieve the subject profile and other categorization related details from this parameter.

Please state if you have some other specific query.

Hope this helps!

Regards,

Saumya

Former Member
0 Kudos

Hi Saumya,

I execute the FM for a specific Service Order number but it only show me the value of a Code (002) which belongs to a Code Group (ZCUTR). And that value is related to the Level 2. It does not show any value of the Code Group ZMUTR which is related to Level 1.

Any advice?

Thanks a lot!

Pablo

saumya_govil
Active Contributor
0 Kudos

Hi Pablo,

If you just wish to find out the relationship between the categories then you can also refer to the tables QPGT and QPCT.

These tables stores the category details.

Regards,

Saumya

Former Member
0 Kudos

Hi

Please use BOL programming code rather than serching for the api's and all..as per my knowledge no API's availabel to get those level's...so please write BOL code and get all details..

Former Member
0 Kudos

Thanks to all of you!

However, I found a way to get the Level 1 from the Level 2 that is store in table CRMD_SRV_SUBJECT. When customizing the Codes of the Code Groups, I wrote a 4 character code which consist of the following:

Example:

"0305" is the code for the level 2 "05" which is related to the "03" level 1. Then it is useful for the Develepment where we need to know both level chosen in the Service Orders. In that way, we can get both Level 1 and Level 2 from the value of the Level 2.

Best regards,

Pablo

Former Member
0 Kudos

Hello Saumya..

I have a similar requirement to read the subject profile & reason categories from the Webui. Can you please elaborate on how to achieve it?

Thanks

Former Member
0 Kudos

Hi Jula

Have you found the answer for your query ?

I found one way of finding it.

Regards

Logu

Former Member
0 Kudos

Hello Logu,

we are yet to find a way.. Can you please share your thoughts on it ?

Regards

Sweta

former_member191572
Contributor
0 Kudos

Hi,

Please use the Utilities class CL_CRM_ML_Category_util and method get_categories will provide the category details based on the header guid u r passing.

Former Member
0 Kudos

Hi  Sweta,

I  have created a new Custom FM to figure out all the Problem codes for an ORder.

In my case i have Four levels.

So I found Four codes and description based on the below logic.

You could use where used list for this Standard FMs.

ET_SCHEMA will have all the problem codes.

IF ( it_subject IS SUPPLIED ) AND ( it_subject IS NOT INITIAL ).
    lt_subject = it_subject.
  ELSE.
    IF iv_header_guid IS NOT INITIAL.
      CALL FUNCTION 'CRM_SUBJECT_READ_OW'
        EXPORTING
          iv_ref_guid    = iv_header_guid
          iv_ref_kind    = 'A'
        IMPORTING
          et_subject_wrk = lt_subject
        EXCEPTIONS
          error_occurred = 1
          OTHERS         = 2.
      IF sy-subrc <> 0.
* Implement suitable error handling here
      ENDIF.
    ENDIF.
  ENDIF.
  READ TABLE lt_subject INTO ls_subject WITH KEY ref_kind = 'A'.
  IF sy-subrc = 0.
    lv_cat_id = ls_subject-cat_id.
  ENDIF.

  CALL FUNCTION 'CRM_ERMS_CAT_CA_READ'
    EXPORTING
      iv_cat_id           = lv_cat_id
    IMPORTING
      et_cat_guid         = lt_categ_guid
    EXCEPTIONS
      non_existent        = 1
      non_existent_aspect = 2
      data_error          = 3
      OTHERS              = 4.
  IF sy-subrc <> 0.
* Implement suitable error handling here
  ENDIF.
  READ TABLE lt_categ_guid INTO ls_categ_guid INDEX 1.
  IF sy-subrc = 0.
    lv_cat_guid = ls_categ_guid.
    CALL FUNCTION 'CRM_ERMS_CAT_CA_READ'
      EXPORTING
        iv_cat_guid         = lv_cat_guid
      IMPORTING
        et_cat              = lt_cat
      EXCEPTIONS
        non_existent        = 1
        non_existent_aspect = 2
        data_error          = 3
        OTHERS              = 4.
    IF sy-subrc <> 0.
* Implement suitable error handling here
    ENDIF.
    READ TABLE lt_cat INTO ls_cat INDEX 1.
    IF sy-subrc = 0.
      lv_asp_guid = ls_cat-cat-asp_guid.
    ENDIF.
  ENDIF.
  ls_query-tree_guid = lv_asp_guid.
  ls_query-node_guid = lv_cat_guid.
  lv_level = '4'.

  CALL FUNCTION 'CRM_ERMS_CAT_HI_PARS_LEVEL'
    EXPORTING
      iv_hier_query  = ls_query
      iv_level       = lv_level
*     IV_INNER_NODES = 'X'
    IMPORTING
      et_hier        = lt_cat_all.

  LOOP AT lt_cat_all INTO ls_cat_all.

    CALL FUNCTION 'CRM_ERMS_CAT_CA_READ'
      EXPORTING
        iv_cat_guid         = ls_cat_all-node_guid
      IMPORTING
        et_cat              = lt_cat
      EXCEPTIONS
        non_existent        = 1
        non_existent_aspect = 2
        data_error          = 3
        OTHERS              = 4.
    READ TABLE lt_cat INTO ls_cat INDEX 1.
    IF sy-subrc = 0.
      APPEND ls_cat TO et_schema.
    ENDIF.
  ENDLOOP.

Thanks

Logu