Monday, 9 July 2012

BOL Porgramming - Query Objects


*Get the BOL Core instance
DATA: lr_core1 TYPE REF TO cl_crm_bol_core.
*Load the component set Or Component
lr_core1 = cl_crm_bol_core=>get_instance( ).
lr_core1->start_up( 'BP_APPL' ).

*Determine Query Services Available
DATA:lv_obj_model  TYPE REF TO if_genil_obj_model.
lv_obj_model = cl_crm_genil_model_service=>get_runtime_model( ).

DATA:lt_query_names TYPE crmt_ext_obj_name_tab.
CALL METHOD lv_obj_model->get_object_list
  EXPORTING
    iv_object_kind     = if_genil_obj_model=>query_object
*    iv_ws_enabled_only = ABAP_FALSE
  IMPORTING
    et_object_list     = lt_query_names.


*Select Perticular Query
DATA:lv_query_name TYPE crmt_ext_obj_name.
READ TABLE lt_query_names INTO lv_query_name INDEX 6. "'BuilContactPersonSearch'

*Create Query Service by passing the search object name
DATA:lv_query TYPE REF TO cl_crm_bol_query_service.
lv_query = cl_crm_bol_query_service=>get_instance(
                  iv_query_name = lv_query_name ).

*Set Search Criteria
lv_query->set_property( iv_attr_name = 'BP_NUMBER'
                        iv_value = '0000311966' ).

*Read Search Criteria
DATA:lv_city TYPE string.
lv_city = lv_query->get_property_as_string( 'BP_NUMBER' ).

*Executer Query and Receive Result
DATA:lv_result_tab TYPE REF TO if_bol_entity_col.  "To Capture Multiple Records
lv_result_tab = lv_query->get_query_result( ).

No comments:

Post a Comment