There are two main types of objects in the BOL: business objects (entities) and query services. You can find an overview of the available query services and BOL objects in the BOL browser (Transaction GENIL_MODEL_BROWSER). You can use query services to search for specific business objects within the BOL. A query service is represented by a query object, which is managed by a Query Manager (also an object).The BOL Browser (Transaction GENIL_BOL_BROWSER) can be used to test the query services and BOL objects.
There are two types of query objects: a) Query Objects and b) Dynamic Query Objects. In this document I am going to illustrate two examples to use query objects in BOL programming:
Here is the testing screen for normal query objects where we can pass the values for query parameters and execute the query.
The handler class for query objects: CL_CRM_BOL_QUERY_SERVICE. The methods mentioned in this class can be used to execute a business query. Here are the steps:
Step1: Create an instance of the query object using the method GET_INSTANCE of the handler class.
Pass the name of the query object to importing parameter IV_QUERY_NAME.
DATA: lr_queryservice TYPE REF TO cl_crm_bol_query_service.
Step2: Set the query parameters using method SET_QUERY_PARAMETERS of the handler class. Pass the parameters to the importing parameter IT_PARAMETERS. IT_PARAMETERS is an internal table with two fields name and value.
DATA: lt_parameters TYPE crmt_name_value_pair_tab, ls_parameters TYPE crmt_name_value_pair.
***Fill the internal table with parameter name and values entries based on which query will be executed
Step2: In this step we need to maintain the query selection parameters. As we can see from the model browser test screen, there are no predefined selection parameters whose value we can set as we did in the earlier case. Here we need to add selection parameters. Use method ADD_SELECTION_PARAM of the handler class to add the selection parameters
CHECK lr_queryservice IS BOUND.
CALL METHOD lr_queryservice->add_selection_param
iv_attr_name = 'OBJECT_FAMILY'
iv_sign = 'I'
iv_option = 'EQ'
iv_low = ‘0401’
iv_high = ''.
Step3: After we add the query object selection parameters we can use the method GET_QUERY_RESULT of the handler class to get the query result as a collection of entities.
DATA: lr_queryresult TYPE REF TO if_bol_entity_col.