Skip to Content
0
Dec 08, 2009 at 09:54 AM

Performance in Organization Unit search with Filters

23 Views

Dear Experts,

We are facing a issue with one of our development.

We have a requirement where we need to filter the result of searching of Organization Unit on the basis of some conditions. We have written the code and the functionality is working fine with the lesser number of records but when we try to test it in Quality system, the filtration is taking lot of time to show us the result.

I am enclosing the code which we have written to filter the result in searching of Organization.

METHOD filter_relevant_orgs.
*--------------------------------------------------------------------*
*  DATA ls_attributes TYPE crmt_genil_orgheader_attr.
  DATA ls_attributes TYPE crmt_genil_orgattr_attr.
*  DATA lv_werks TYPE werks_d.
*--Referencias-------------------------------------------------------*
  DATA iterator      TYPE REF TO if_bol_bo_col_iterator.
  DATA attr_iterator TYPE REF TO if_bol_bo_col_iterator.
  DATA entity        TYPE REF TO cl_crm_bol_entity.
  DATA attribute     TYPE REF TO cl_crm_bol_entity.
  DATA orgunit       TYPE REF TO cl_crm_bol_entity.
  DATA coll          TYPE REF TO cl_crm_bol_entity_col.
  DATA lr_result     TYPE REF TO cl_crm_bol_entity_col.
*--------------------------------------------------------------------*

  CREATE OBJECT lr_result.
  iterator ?= cr_result->get_iterator( ).

  entity ?= iterator->get_first( ).
  WHILE entity IS BOUND.
    TRY.
        orgunit ?= entity->get_related_entity( iv_relation_name = 'OrgHeaderOrgunitR' ).
        CHECK entity IS BOUND.
        coll ?= orgunit->get_related_entities( iv_relation_name = 'OrgUnitAttributesR' ).
        CHECK coll IS BOUND.
        attr_iterator ?= coll->if_bol_bo_col~get_iterator( ).
        CALL METHOD attr_iterator->filter_by_property
          EXPORTING
            iv_attr_name = 'SCENARIO'
            iv_value     = 'SERVICE'.

        CALL METHOD attr_iterator->filter_by_property
          EXPORTING
            iv_attr_name = 'ATTRIB'
            iv_value     = 'ZVAL'.
        attribute ?= attr_iterator->get_first( ).
        WHILE attribute IS BOUND.
          attribute->get_properties( IMPORTING es_attributes = ls_attributes ).
          IF ls_attributes-attrib EQ 'ZVAL' AND
             ls_attributes-low    EQ abap_true.
            lr_result->if_bol_bo_col~add( EXPORTING iv_entity = entity ).
            EXIT.
          ENDIF.
          attribute ?=  attr_iterator->get_next( ).
        ENDWHILE.

      CATCH cx_crm_genil_model_error .
    ENDTRY.

    entity ?= iterator->get_next( ).
  ENDWHILE.

  cr_result ?= lr_result.

ENDMETHOD.

We are just passing the result from standard organization search functionality to our filter method. Please help us if we can optimize this code further to get the better performance on same.

Any help will be highly appreciated.

Thanks,

Best Regards,

Deepak Gupta