2012 Jan 12 7:38 AM
Hi Experts!
I have a very simple question. I have a list of partner guids, so how can I process the searching for appropriate business partners' entities via CL_CRM_BOL_DQUERY_SERVICE methods (or something else)? So I just need to make a search for multiple values for one search criterion at the same time (logical OR), how?
Thank you!
Edited by: Mr.Tourette on Jan 12, 2012 8:38 AM
2012 Jan 12 3:26 PM
Hi,
If you just want the bol entity of a certain object, you can use following code:
data: lr_core type ref to cl_crm_bol_core.
lr_core = cl_crm_bol_core=>get_instance( ).
* create root object
TRY.
CALL METHOD lr_core->get_root_entity
EXPORTING
iv_object_name = 'BuilHeader'
iv_object_guid = lv_guid
RECEIVING
rv_result = lr_entity.
CATCH cx_crm_genil_model_error .
RETURN.
ENDTRY.The builheader entity name can be changed to other root enities as well.
Kind regards.
Hi Experts!
I have a very simple question. I have a list of partner guids, so how can I process the searching for appropriate business partners' entities via CL_CRM_BOL_DQUERY_SERVICE methods (or something else)? So I just need to make a search for multiple values for one search criterion at the same time (logical OR), how?
Thank you!
Edited by: Mr.Tourette on Jan 12, 2012 8:38 AM
2012 Jan 12 3:26 PM
Hi,
If you just want the bol entity of a certain object, you can use following code:
data: lr_core type ref to cl_crm_bol_core.
lr_core = cl_crm_bol_core=>get_instance( ).
* create root object
TRY.
CALL METHOD lr_core->get_root_entity
EXPORTING
iv_object_name = 'BuilHeader'
iv_object_guid = lv_guid
RECEIVING
rv_result = lr_entity.
CATCH cx_crm_genil_model_error .
RETURN.
ENDTRY.The builheader entity name can be changed to other root enities as well.
Kind regards.
2012 Jan 13 7:19 AM
Yes I know, but I want to get entity collection of several guids. Surely I can make it using loop for each entity, but it seems to be not very optimal in execution time.
Don't you know the way to do it?
2012 Jan 13 8:37 AM
Hi,
Seems like you are right Mr. Tourette.
I've created a small FM to test performance of both methods of working and one BOL query containing all the guids outperforms the GET_ROOT.
Afterwards, this seemed logic to me as well (what was i thinking?!). The BOL query will only use one SQL query, as the GET_ROOT will use multiple.
I will insert the code of my test FM, so you can compare both methods and implement the query.
DATA: lt_guids TYPE TABLE OF crmt_object_guid.
DATA: lr_core TYPE REF TO cl_crm_bol_core.
DATA: lr_col TYPE REF TO if_bol_bo_col.
DATA: lr_entity TYPE REF TO cl_crm_bol_entity.
DATA: lr_qs TYPE REF TO cl_crm_bol_dquery_service.
DATA: lv_low TYPE string.
DATA: lv_start TYPE timestamp.
DATA: lv_end TYPE timestamp.
DATA: lv_diff TYPE timestamp.
FIELD-SYMBOLS: <guid> LIKE LINE OF lt_guids.
*startup
SELECT partner_guid UP TO 1000 ROWS FROM but000 INTO TABLE lt_guids WHERE name_last LIKE 'A%'.
lr_core = cl_crm_bol_core=>get_instance( ).
lr_core->start_up( iv_appl_name = 'ALL' ).
*with get root entity:
CREATE OBJECT lr_col TYPE cl_crm_bol_bo_col.
if scenario = 1.
GET TIME STAMP FIELD lv_start.
LOOP AT lt_guids ASSIGNING <guid>.
TRY.
CALL METHOD lr_core->get_root_entity
EXPORTING
iv_object_name = 'BuilHeader'
iv_object_guid = <guid>
RECEIVING
rv_result = lr_entity.
lr_col->add( lr_entity ).
CATCH cx_crm_genil_model_error .
RETURN.
ENDTRY.
ENDLOOP.
GET TIME STAMP FIELD lv_end.
rv_get_root = lv_end - lv_start.
else.
*search for all entities at once
lr_qs = cl_crm_bol_dquery_service=>get_instance( iv_query_name = 'BuilHeaderAdvancedSearch' ).
lr_col->clear( ).
GET TIME STAMP FIELD lv_start.
LOOP AT lt_guids ASSIGNING <guid>.
lv_low = <guid>.
lr_qs->add_selection_param( iv_attr_name = 'PARTNER_GUID'
iv_sign = 'I'
iv_option = 'EQ'
iv_low = lv_low
).
ENDLOOP.
lr_col = lr_qs->get_query_result( ).
GET TIME STAMP FIELD lv_end.
rv_query = lv_end - lv_start.
endif.
2012 Jan 13 8:54 AM
2012 Jan 13 9:06 AM
I don't think you can compare the instantiation of BOL-objects with a simple sql query.
The BOL-objects are going to get a lot more data from multiple tables (so not only BUT000).
Kind regards,
2012 Jan 13 1:22 PM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |