Skip to Content
Author's profile photo Harel Gilor

Create your own BOL Object

Using the BOL and its uniform application programming interface (API) to access business

data offers considerable advantages compared to the various APIs typically available for
business objects:

1) The object-oriented BOL API is simple, uniform, and easy to use.

2) The built-in buffer accelerates your applications.

3) You can isolate your programs from any interface changes in the underlying business
    object-specific APIs.

4) Development of SAP CRM applications is easy since the BOL has been designed to work hand-in-hand  with the UI parts of the CRM WebClient UI framework.

It is possible to enhance the BOL to cover business data not yet supported. After the
corresponding business objects and query services have been modeled and implemented,
you can use them at runtime.

Usually we are not need to build a BOL object. We will end up changing the existing BOL. I came across a situation that I need a screen for a component and create a screen for add/ modify and search the Z table.

In this post let us see how we create a custom BOL object for a Z table. Once this bol is create we need to add this bol in the custom view and show that on the screen. For now let us see how we can create a custom BOL.

Let’s create a z table . See the following screen shot for the table.

Let us use this table and create a bol for this table to add,modify and search data.


 OK. Now we need to define two tables. One for the data elements that we are going to use in the BOL and another for the hierarchy of the data element that we are going to use in the BOL object. Once these table are defined then we need to mention the class module that we are going to use for the BOL object. All these information are configured in the spro for this bol object.

See the following screen shot.


In the above configuration if you enter the Basic setting you will see all the BOL object defined here.
OK for our custom let us define the bol object as ZBOLOB.
See the following screen. 


Now select the component Definition(the first one) and click on the new entries. Let us define the BOL component and add the details.
See the following screen.


Add a Component Set Definition. See the follow screen shot.


 Now assign the Component definition to the component set definition.
See the following screen shot.

Now the BOL component is assigned to the Component Set definition. You can assign More than one BOL component to the component set.

Now we need to create one implementation class and two tables one is Object table and another is Model table. Now let us create all these object.

One important thing with creating the implementation class is you need to specify super class for this implementation class and redefine specific methods.

For Creation a record, editing the record (modify) and for Searching you have redefine specific super class methods. While creating views (insert, edit and search) you need to specify specific Super class(not the methods).
See the following screen shots.


and ZBOL_MODEL table


Now we need to define a check table  . 

See the following screen shots.

don’t forget to Activate your tables .

Now let us create the data structure and add the structure and the data structure model in this BOL object tables. For this example this is a plain simple data structure and I am going to add the hierarchy for search.

See the following screen shot for the structure.

Now add this information in the BOL object Tables. Look at the following infomration I entered in the table. Always the object table needs to have a root object and the other object that are associated to their parent. Here all the object are associated to the root. If you have complex hierarchy then it takes time to do the correct design and come up with the information. Always try to see the existing code in the sap component and try to use that , this way it will be always easy to follow.
See the following screen shot for the data.

and for the relation

In this example we have only one relation ship and all the result and search structure belongs to the root node.

Now let us create the implementation class for this BOL.

go to SE24 Transaction Create a new class ZCL_OWN_BOL using the class CL_CRM_GENIL_ABSTR_COMPONENT2 as super class. This is very important. If you didn’t inherit that super class they BOL object don’t understand your z class module. See the following screen shot for the bol implementation class module creation.

Now you need to redifine the methods from the super class. Because we are planning this bol object for search let us redefine all the methods that are associated for search.
See the following screen shot.

Now you need to change the code in all the above method to fit your bol objects. First let us put our bol tables in this Get_Objects and Get_Model. See the following code cut and paste in the right methods.


Code For The Methods

<br />METHOD if_genil_appl_intlay~get_dynamic_query_result.<br />  DATA:   lr_object       TYPE REF TO if_genil_cont_root_object,<br />          lt_result       TYPE TABLE OF zusr_bol_st.</div><div style=”text-align: left”>  FIELD-SYMBOLS: <lfs_result> TYPE zusr_bol_st.</div><div style=”text-align: left”>  SELECT * FROM zusr_bol_tb INTO TABLE lt_result.</div><div style=”text-align: left”>  LOOP AT lt_result ASSIGNING <lfs_result>.<br />    lr_object = iv_root_list->add_object( iv_object_name = ‘Root'<br />                                          is_object_key  = <lfs_result>-bname ).<br />    CHECK lr_object IS BOUND.<br />     lr_object->set_query_root( abap_true ).<br />  ENDLOOP.</div><div style=”text-align: left”>ENDMETHOD.</div><div style=”text-align: left”><br />METHOD if_genil_appl_intlay~get_objects.<br /><br />DATA: lr_object TYPE REF TO if_genil_container_object,<br /><br />lr_msg_cont TYPE REF TO cl_crm_genil_global_mess_cont,<br /><br />lv_name_obj TYPE zusr_bol_tb-bname,<br /><br />lr_attr_props TYPE REF TO if_genil_obj_attr_properties,<br /><br />l_result TYPE zusr_bol_st,<br /><br />lv_name TYPE crmt_ext_obj_name.<br /><br />lr_object = iv_root_list->get_first( ).<br /><br />lr_msg_cont ?= iv_root_list->get_global_message_container( ).<br /><br />WHILE lr_object IS BOUND.<br /><br />lv_name = lr_object->get_name( ).<br /><br />IF lr_object->check_attr_requested( ) = abap_true.<br /><br />lr_object->get_key( IMPORTING es_key = lv_name_obj ).<br /><br />SELECT SINGLE * FROM zusr_bol_tb<br /><br />INTO CORRESPONDING FIELDS OF<br /><br />l_result WHERE bname = lv_name_obj.<br /><br />lr_object->set_attributes( l_result ).<br /><br />lr_attr_props = lr_object->get_attr_props_obj( ).<br /><br />lr_attr_props->set_all_properties( if_genil_obj_attr_properties=>read_only ).<br /><br />ENDIF.<br />lr_object = iv_root_list->get_next( ).<br /><br />ENDWHILE.<br /><br />ENDMETHOD. <br />  <br />METHOD if_genil_appl_model~get_model. <br /><br /><br />SELECT * FROM zbol_model<br /><br />INTO CORRESPONDING FIELDS<br /><br />OF TABLE rt_relation_det.<br /><br />ENDMETHOD. <br />  <br />METHOD if_genil_appl_model~get_object_props. <br /><br /><br />SELECT * FROM zbol_object<br /><br />INTO CORRESPONDING FIELDS OF TABLE<br /><br />rt_obj_props[].<br /><br />ENDMETHOD. <br />*

End Of Code—

Now compile the code and let us go the the BOL browser and execute this object and see if this is working.

Go to the Transaction GENIL_BOL_BROWSER.
Now give the bol component name. Ours is ZBOLOB.
See the following screen shots.

See the following screen shot for the records in the z table. Double click on the Search.

you should see the Object browse and the dynamic parameter on the right hand side.

See the screen shots below.

i added the following lines to my z table and here you can do the same as you want to add. 

 Remove the line in the dynamic Query Parameter using the – sign and click fine this will return all the records. Double click on the values and you will see the rows.

See the following screen shots.

Once we got the results then this gives us that our BOL object is working.

Now if you hit the children button you’l get the predefined relation that we define eralier .
See the following screen shots.


Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Paolo Romano
      Paolo Romano
      Best blog of this year, really useful Herzel!!! Looking for it some month ago, but never found one so clear!

      Thank you a lot!

      Author's profile photo Former Member
      Former Member

      is that usable on SAP ECC or only on SAP CRM?
      Thanks for great blog!

      Author's profile photo Harel Gilor
      Harel Gilor
      Blog Post Author
      Well ,

      if you try to execute GENIL_BOL_BROWSER & GENIL_MODEL_BROSER transaction in ECC 6.00 environment you'll see that they are there.

      there's not much data and BOL objects there and i assume that the solution of ECC yet not fully prepared for it .

      my personal opinion is that SAP is going to implement the concept of Genil & Bol within the entire ECC system , but ther's no official publication for that and there's no doubt that this is the future of development in the SAP environment.

      Author's profile photo François Henrotte
      François Henrotte

      From Basis Component 7.02 the GenIL is ok to use on non-CRM SAP system.

      Also the Component Workbench and the BSP extension CHTMLB.

      Author's profile photo Sreekanth Gollamudi
      Sreekanth Gollamudi
      Very nice Blog...
      Author's profile photo Harshit Kumar
      Harshit Kumar
      Hi Harel,

      Good and informative Blog. For some reason i am not able to view the screenshots, could you please check with the Moderator?


      Author's profile photo Suchita Phulkar
      Suchita Phulkar
      A very need and nice Blog !!


      Wish you all the success !!

      Author's profile photo Former Member
      Former Member
      cann't see the picture now .
      Author's profile photo Harel Gilor
      Harel Gilor
      Blog Post Author
      scroll down till the bottom of the page and you'll see the horizontal scroll bar.
      Author's profile photo Former Member
      Former Member
      Thanks for the blog.
      I've done the steps as it is. But i am not able to see any entries in the search objects screen(Tcode :genil_bol_browser). I entered entries in table :ZUSR_BOL_TB also.
      I am using CRM 7.0 system
      Can anyone please tell me where i cud be wrong.


      Author's profile photo madhup mudiraj
      madhup mudiraj

      I really liked the blog and was partially satisfied with working on BOL. If you can reload this blog, so that the un-cut screen shot can be visible


      Author's profile photo Former Member
      Former Member
      HI Harel,

      Very Nice and complete Blog. I understand the basic of BOL programming through this.

      I have one question though, I am manage to implement Search Object, but on this Insert and Delete is not working.

      What more changes i need to do in BOL Class to support Insert or delete.


      Author's profile photo Former Member
      Former Member
      I am unable to see the screenshots.
      Could you pls look into it.
      Author's profile photo Former Member
      Former Member

      Hi all,

      I happen to find the same blog in

      sharing the link with u all, the screen shots are all available in it.