difference between bol and genil layers in sap crm

Upload: bhanu-chander

Post on 02-Nov-2015

414 views

Category:

Documents


1 download

DESCRIPTION

Difference Between BOL and GENIL Layer

TRANSCRIPT

Yes there is a difference between BOL and GENIL Layers in SAP CRM :Often you would come across people who would interchangeably use BOL & GENIL. But if there are two separate layers created then definitely they would have two very different semantics. This comes from my knowledge as a framework owner in Business by Design(ByD). And I would say that both the layers are created for two very different purposes.The BOL layer provides a consistent interface to access the business objects APIs or the underlying data fetching APIs using the GENIL framework. The BOL object uses the object oriented approach to access the model. So whether you are accessing a standard object or an enhanced object, you dont have to worry. All you need to know is the name of the Context, Context Node and then you are good to go. Tomorrow even if there is an implementation change you are not affected as the interface over which you have written your data fetch logic remains the same. This is very good advantage over the conventional programming where the business logic is present in the UI itself. If the business logic changes you have to update at all the respective places. But here there is a clear separation between the business logic and the UI. And the UI is not affected by the change of business logic as long as there is no change in the interface, which in itself is rare as an a interface is timeless and changes very rarely.The BOL also acts as the buffer for the UI.BOL layer is thus specifically built by SAP specifically for SAP CRM Web UI and is available only at the runtime.GENIL is the generic interaction layer which provides you access to the business logic which is present in the Business object. As compared to BOL, GENIL can also be used for scenarios other than the Web UI. Consider the case where a user wants to execute a web service to fetch some data in a non Web UI scenario. In this case there is no need for BOL layer at all. You can directly connect to the GENIL Layers and fetch the needed data. In case of Web UI scenarios, we would need to use both GENIL & BOL Layers.The GENIL represents the model of the component that you are planning to use. During the design time, you prepare a model for the GENIL. The objects involved in GENIL are specified in the Object Tables and the model tables. GENIL would be represented by an ABAP class and the object table and model table are specified in the programming so as to realize the actual model. This model can be depicted in design time using the GENIL_MODEL_BROWSER.Read myBlogfor more details on these tools.GENIL atrun timeis needed to fetch the data from the Business objects or the underlying APIs. If you want to test the GENIL runtime behavior, use GENIL_BOL_BROWSER. As the name suggests, this involves both the GENIL & BOL layers because this is a developer tool provided by SAP to test the backend functionality in case of Web UI scenarios.One also needs to understand the transactional behavior of SAP CRMa) SET_PROPERTY -> This method on the entity is used to make changes in the BOL Buffer level.b) MODIFY-> This method on BOL CORE is used to flush the changes from BOL BUFFERS to GENIL BUFFERS.c) COMMIT -> This method on Transaction Context is used to persist the changes from the BOL Buffer to the BO tables.The GENIL Buffers would be cleared after this.d) ROLLBACK -> This method on Transaction Context is used to reject the changes on the GENIL Buffers. This would also clear GENIL buffers.Now this piece of code would be perfect for everyone to understand the difference

data: qs type ref to cl_crm_bol_query_service,result type ref to if_bol_bo_col, ent type ref to cl_crm_bol_entity.qs = cl_crm_bol_query_service=>get_instance( 'BTQuery1O' )." This is for loading the GENIL component for use in BOL programmingqs->set_property( iv_attr_name = 'OBJECT_ID' iv_value = '0005000000' )." This operation sets the value in BOL structuresresult ?= qs->get_query_result( )." Fetches the query resultent ?= result->get_first( ).ent = ent->get_related_entity( 'BTOrderHeader' ).check ent->lock( ) = abap_true.data: descr type crmt_process_description.ent->get_property_as_value( exporting iv_attr_name = 'DESCRIPTION' importing ev_result = descr ). " concatenate descr 'changed' into descr separated by space.ent->set_property( iv_attr_name = 'DESCRIPTION' iv_value = descr )." This operation would effectively highlight the difference. This operation just populates the BOL buffers and genil layer is not populatedcore->modify( )." When the modify is performed on the BOL Core , the BOL changes are flushed to the GENIL Layerdata: tx type ref to if_bol_transaction_context.tx = ent->get_transaction( ).if tx->save( ) = abap_true. tx->commit( )." With this operation the changes are saved to the underlying Business Objects and the Genil buffers are emptyelse. tx->rollback( )."With this the changes are cleared from the GENIL buffersendif.