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 don’t 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 my Blog for more details on these tools.
GENIL at run time is 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 CRM
a) 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