Header Ads

SAP CRM Programming : BOL

The below guide includes most of the details required to code in CRM:

The steps are as given below . 
  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 use the GENIL_BOL_BROWSER

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
NOTE :  REFER http://sapcrmtutorial.blogspot.com/2012/01/concepts-of-bol-programming-getcurrent.html 

-----------------------------------------------------------------------------------

The BOL API consists of various interfaces and classes that you can use to access business
data:
􀁸 CL_CRM_BOL_QUERY_SERVICE
You use this class to select business objects.
􀁸 CL_CRM_BOL_ENTITY
You use this class for implementing business objects.
􀁸 IF_BOL_TRANSACTION_CONTEXT
You use this interface to control transaction behavior.
􀁸 IF_BOL_BO_COL
You use this interface to provide collections to hold business objects.

Access Properties and Related Entities
The following code shows how to access entities of the query result and how to read their
properties. Note that the methods are the same for all types of business objects.
Syntax
* Use iterator to access entities in query result

*""""""""""""""""""""""""""""""""""""""""""""""""""""""*
DATA:lv_iterator TYPE REF TO if_bol_entity_col_iterator.
1 Business Object Layer
14 <July 2008>
lv_iterator = lv_result->get_iterator.
DATA: lv_entity TYPE REF TO cl_crm_bol_entity.
lv_entity = lv_iterator->get_first( ). “Entity is business partner
here
WHILE lv_entity IS BOUND.
* Access attributes of business objects selected
DATA: lv_firstname TYPE string,
lv_lastname TYPE string.
lv_firstname = lv_entity->get_property_as_string( ‘FirstName’ ).
lv_lastname = lv_entity->get_property_as_string( ‘LastName’ ).
* Get a 1:1 related entity
DATA: lv_default_address TYPE REF TO cl_crm_bol_entity.
lv_default_address = lv_entity->get_related_entity(
‘DefaultAddress’ ).
* Get a list of 1:N related entities
DATA: lv_addresses TYPE REF TO if_bol_entity_col.
lv_addresses = lv_entity->get_related_entities( ‘Addresses’ ).
*
lv_entity = lv_iterator->get_next( ).
ENDWHILE.
*""""""""""""""""""""""""""""""""""""""""""""""""""""""*



Contact us for all your SAP Consulting , Implementation and Support requirements www.anniesummerconsulting.com


It will be very helpful if you can visit my youtube channel 
https://www.youtube.com/user/nkbhatt

Donate ETH:  0x4ae0be2fd21779f39d2e3be51aac3973de67b37a
Donate BTC: DRq7gASSRVV3SZxqLHpTe2PQ3chuYFw1jo
Donate LTC: LWqCXBUBtHNQL2chM4AQhCmJ7C3eSNU5bJ
Donate:DOGE: DRq7gASSRVV3SZxqLHpTe2PQ3chuYFw1jo

Powered by Blogger.