cancel
Showing results for 
Search instead for 
Did you mean: 

CRM7 - How do I Read in the Main Catagory for selected row in IC inbox

0 Kudos

Hi experts,

I am using the BAdi "CRM_IC_INBOX_BADI", method "XABLE_BUTTONS_FOR_SELECTION" to disable certain buttons depending on the main catagory of the row selected from the IC inbox.

The problem I have is I don't know how to use the appropriate classes / methods to obtain what I need. I should also point out were only interested in single selected rows as multiple rows are excluded.

If I place a breakpoint in the method and then select a row in the IC inbox the BAdi is triggered.  The BAdi has an import parameter "I_SELECTED_INBOX_ITEMS" which is of type "CL_CRM_BOL_ENTITY_COOL" and when I click on this I can see all the attributes. The attribute I'm interested in here is "ENTITY_LIST" and If I click on ENTITY_LIST another BO reference is shown "->{0:4800*\CLASS=CL_CRM_AUI_ONEORDER} which has the attribute "GV_MAINCATEGORY" which I would like to read in. Can anyone help or offer some sample code?

Thanks in advance,

Chris

Accepted Solutions (1)

Accepted Solutions (1)

VishnAndr
Active Contributor
0 Kudos

Hello, Chris.

Try something like this:

DATA: lr_item TYPE REF TO cl_crm_aui_oneorder,

            lv_maincategory TYPE CRMT_AUI_MAINCAT.

try.

  lr_item ?= i_selected_inbox_items->get_first( ).

  lv_maincategory = lr_item->gv_maincategory. //as far as it is a public attribute

catch cx_root.

endtry.

0 Kudos

Hi Andrei and thanks that worked great.. The only thing I needed to add was the name of the interface when calling the get_first method, see below.

DATA: lr_item TYPE REF TO cl_crm_aui_oneorder,
             lv_maincategory TYPE crmt_aui_maincat.

       TRY.
           lr_item ?= i_selected_inbox_items->if_bol_entity_col~get_first( ).
           lv_maincategory = lr_item->gv_maincategory. "//as far as it is a public attribute

         CATCH cx_root.
       ENDTRY.

0 Kudos

Hi,

I've been testing this and came accross an issue I need help with.

From the Agents inbox, if I search for a selection of Employee requests or interaction records and then select either of these from the resulting list the BAdi is triggered and the main catagory is retrieved. However, when I select an email I don't get a main catagory returned. When following in debug I noticed the exception CX_SY_MOVE_CAST_ERROR occurs on the code line

lr_item ?= i_selected_inbox_items->if_bol_entity_col~get_first( ).

Any help or advice would be very much appreciated,

Thanks

Chris

Sigrid
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

you have defined lr_item of type cl_crm_aui_oneorder which works for inbox items of type ONEORDER but Inbox mails are entities of type CL_CRM_AUI_WORKITEM.  

You might try with superclass CL_CRM_AUI_ENTITY.

Best Regards,

Sigrid

0 Kudos

Hi Sigrid,

Thank you for your response. I've now added the following:

data: lr_wrkitm type ref to cl_crm_aui_entity.

lr_wrkitm ?= i_selected_inbox_items->if_bol_col_entity~get_first.

lv_maincategory = lr_wrkitm->gv_maincategory.

When I follow this in debug there is no casting error now but there isn't any value in the GV_MAINCATEGORY field like there is when processing a ONEORDER type. Have I missed something? Or is there anything else I can do?

Thanks,

Chris

Sigrid
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Chris,

I did not try myself but actually gv_maincategory is only useful for inbox items of type OneOrder, so you might use a try/catch block when casting to an lr_item_oneorder of type cl_crm_aui_oneorder?

Best Regards,

Sigrid

0 Kudos

Hi Sigrid,

I now understand I can't read the main category for a work item.

What I've done is to read in the item type for any work items that are selected.

data: lr_wrkitm type ref to cl_crm_aui_entity,

        lv_item_type type crmt_aui_item_type.

lr_wrkitm ?= i_selected_inbox_items->if_bol_col_entity~get_first.

lv_item_type = lr_wrkitm->get_property_as_string( iv_attr_name = 'ITEM_TYPE' ).

Thanks and regards,

Chris

Answers (0)