Skip to end of metadata
Go to start of metadata

Hi This is an example of BOL Programming , In the Given Program I would like to explain Fetching data from the BOL Layer for this we need to do these steps 

  1. Get the BOL Core instance 
  2. Load the Component  
  3. Create the Query Instance by passing search Object  
  4. Pass the required attributes  
  5. get the data and process the data.

given below code explains the program technically

Data Declaration :-

DATA: LR_CORE   TYPE REF TO CL_CRM_BOL_CORE,
      LR_QUERY  TYPE REF TO CL_CRM_BOL_QUERY_SERVICE,
      LR_RESULT TYPE REF TO IF_BOL_ENTITY_COL,
      LR_ENTITY TYPE REF TO CL_CRM_BOL_ENTITY,
      LV_STRING TYPE STRING,
      lt_tab    type table of ty_tab with header line.

Types : Begin of ty_tab ,
          value1 type string,
          value2 type string,
          value3 type string,
          value4 type string,
        End of ty_tab.

1) Get the BOL Core instance

lr_core = cl_Crm_bol_core=>get_instance( ).

2 ) Load the component set

LR_CORE->LOAD_COMPONENT_SET( 'BP_APPL' ).


3 )Create the query instance by passing the search object name

lr_query = CL_CRM_BOL_QUERY_SERVICE=>get_instance( iv_query_name = 'BuilContactPersonSearch' ).

4) Pass the required attributes 

Data IT_PARMS TYPE CRMT_NAME_VALUE_PAIR_TAB.
Data WA_PARMS TYPE CRMT_NAME_VALUE_PAIR.

you can observe this data declaration in any standard search and result objects

WA_PARMS-NAME = 'BP_NUMBER'.
WA_PARMS-VALUE = '81'.
Append WA_PARMS to IT_PARMS.

* Add the selection parameters
CALL METHOD LR_QUERY->SET_QUERY_PARAMETERS
  EXPORTING
    IT_PARAMETERS = IT_PARMS.

* Get the result list
LR_RESULT = LR_QUERY->GET_QUERY_RESULT( ).
* here result contains the so many entity to process each and every entity we loop this result entity
* The method get_first is used to fetch first entity of the result list.
* Get the first object(entity) in the result list
LR_ENTITY ?= LR_RESULT->GET_FIRST( ).
* if it contains data then only it process it
* If the entity is bound
WHILE LR_ENTITY IS BOUND.
* Process the parent entity for the required data
* here returning parameter type must be string
  lt_tab-value1 = LR_ENTITY->GET_PROPERTY_AS_STRING( 'BP_NUMBER' ).
  lt_tab-value2 = LR_ENTITY->GET_PROPERTY_AS_STRING( 'DATE_FROM' ).
  lt_tab-value3 = LR_ENTITY->GET_PROPERTY_AS_STRING( 'DATE_TO' ).
  lt_tab-value4 = LR_ENTITY->GET_PROPERTY_AS_STRING( 'FUNCTION' ).
  Append lt_tab.
* Go to the next entity
* The method get_next(0 is used to fetch next entity , if it is bound then it process the next steep , other wise condition fails
  LR_ENTITY ?= LR_RESULT->GET_NEXT( ).
ENDWHILE.
* output
loop at lt_tab .
  write :/ lt_tab-value1,lt_tab-value2,lt_tab-value3,lt_tab-value4.
endloop.

To check whether data is correct or not 

go to tcode : genil_bol_browser-> component set ->  bp_appl  ->  
select search object  --> 
BuilContactPersonSearch
In the right side enter value in attribute  BP_NUMBER = 81 and click FIND button in right top side of the page , then 
we will get data in left side of the screen , click on each entity .


  • No labels

3 Comments

  1. Former Member

    Thank you! This was very helpful.

    Since i am a newbie to SAP CRM and bol programming, can you also tell the use of CL_CRM_BOL_ENTITY and what kind of data does it fetches and all the above other classes whose reference variables you have created.

    Regards

    Sanket Jain

  2. Former Member

    Dear Sadasiva,

    Is there any way to set data to a BOL root or dependency object?

    Thanks & Best Regards

    Eason

  3. Former Member

    what is ty_tab?

    please explaine..