cancel
Showing results for 
Search instead for 
Did you mean: 

Sample code for Badi CRM_IC_INBOX_BADI method AFTER_SEARCH

Subhankar
Active Contributor
0 Kudos

Hi,

I am filtering the search result based on one custom field.

I am able to filter the table C_INBOX_ITEMS.

Can you please provide some sample code to synch C_NATIVE_ITEMS_FOUND .

Thanks

Subhankar

Accepted Solutions (0)

Answers (1)

Answers (1)

BGarcia
Active Contributor
0 Kudos

Hi Subhankar,

The c_native_items_found is a collection of CRM bol entities. So, you must use an iterator to loop trough those entities.

Normally, I use a strategy like this three steps:

1. Copy collection


DATA: lr_bol_entity TYPE REF TO if_bol_entity_col
lr_bol_entity = c_native_items_found->if_bol_entity_col~get_copy( ).

2. Get iterator


DATA  lr_iterator TYPE REF TO if_bol_entity_col_iterator.
lr_iterator =  lr_bol_entity->get_iterator( ).

3. Get first entity and loop the whole collection (and optionally, filter them!)


DATA: lr_entity TYPE REF TO cl_crm_bol_entity.
DATA: lv_value TYPE string.
IF lr_iterator IS BOUND.
  lr_entity = lr_iterator->get_first( ).
  WHILE lr_entity IS BOUND.
    IF lr_entity->get_name( ) = '<Some_object>'.
      lv_value = lr_entity->get_property_as_string( iv_attr_name = '<some_entity_attribute' ).
      IF lv_value = '<some_condition>'.
        c_native_items_found->if_bol_entity_col~remove( lr_entity ). "remove the item
      ENDIF.
    ENDIF.
    lr_entity = lr_iterator->get_next( ).
  ENDWHILE.
ENDIF.

Check if this can help you a little more.

Additionally, there is a BOL cookbook available in SDN that can help you a little more.

Kind regards,

Garcia