Business Object Processing Framework (BOPF) is an infrastructure available for SAP Business Suite to simplify the development process of business applications.
Many modules of SAP such as Environment, Health and Safety (EHS), Transport Management, Commercial Project Management are designed based on BOPF framework.
With this framework the developer can concentrate more on the business logic rather than the development of application infrastructure such as authorization control, buffer management etc. Also, BOPF offers seamless integration with various UI Components (FPM, UI5, OData and etc.), Infrastructure Components (Application Logging, BRF+). As a user we no need to worry about development of adapters or integration layers.
A Business object is a hierarchical tree of nodes.
Similar to the objects in Object Oriented Programming, each Business Object has two parts:
- Attributes and Alternative Keys of Nodes forms the Data Part of the BO.
- Business Logic
- Entities associated with nodes forms the Business Logic Part of the BO.
Fig 1. Business Object
Working with Delegated nodes
Business Objects will have several common properties such as address, text collection, attachments and etc. Instead of maintaining these properties in a node of all BO separately, we can create one Dependent Business Object which can be reused by all the Business Objects during run-time.
These Dependent Object’s Root Node are linked to Delegated Node of other Business Objects i.e. Business Object within another BO. Association will exists between these BOs.
Fig 2. Delegated nodes
The Master Project BO /CPD/PFP_BO_PLAN_HEADER is the Host Object and the BO that are linked to its Delegated nodes are called as Delegated Objects.
Unlike Standard Node, the association key (which is used to retrieve data from a related node) between Delegated Node and Dependent Business Object cannot be derived directly from the Constants Interface. This is because the structure and modelling of the dependent object is not known to the Delegated node of BO until the runtime. The modeling is loaded into the Delegated node only at the run-time.
To solve this we can use the GET_CONTENT_KEY_MAPPING method from the framework Configuration reference. This method will provide the association key between two different nodes that has been generated during runtime.
Fig 3. Delegated object at Runtime
As highlighted in Figure 2, PLAN_HEADER_LONG_TEXT is a Delegated node in the Business Object /CPD/PFP_BO_PLAN_HEADER. This Node is linked to the Root node of the Dependent Business Object /BOBF/TEXT_COLLECTION.
For any CRUD operation over this node we need the Node key and association key which will be available only at the runtime. The Constants Interface for /BOBF/TEXT_COLLECTION Business Object is /BOBF/IF_TXC_C.
Fig 4. Dependent Object
From the below code we will get the Node key and Association key of the Dependent Object’s Node at run-time.
Declare and create Transaction, Service and Configuration instance for master project BO.
DATA : lr_tran_mgr TYPE REF TO /bobf/if_tra_transaction_mgr, lr_serv_mgr TYPE REF TO /bobf/if_tra_service_manager, lr_bo_conf TYPE REF TO /bobf/if_frw_configuration. *-- Transaction Manager Reference lr_tran_mgr = /bobf/cl_tra_trans_mgr_factory=>get_transaction_manager( ). *-- Service Manager Reference *--Export the Business Object Key of the Node lr_serv_mgr = /bobf/cl_tra_serv_mgr_factory=>get_service_manager( iv_bo_key = /cpd/if_mp_pws_bo_c=>sc_bo_key ). *-- Configuration Reference *--Export the Business Object Key of the Node lr_bo_conf = /bobf/cl_frw_factory=>get_configuration( iv_bo_key = /cpd/if_mp_pws_bo_c=>sc_bo_key ).
Get Node key and association key between text nodes.
*-- Node Key of TEXT node lv_txt_key = lr_frw_conf->get_content_key_mapping( iv_content_cat = /bobf/if_conf_c=>sc_content_nod iv_do_content_key = /bobf/if_txc_c=>sc_node-text iv_do_root_node_key = /cpd/if_pfp_bo_plan_hdr_c=>sc_node-plan_header_long_text ). *-- Association Key of ROOT->TEXT lv_txt_assoc = lr_frw_conf->get_content_key_mapping( iv_content_cat = /bobf/if_conf_c=>sc_content_ass iv_do_content_key = /bobf/if_txc_c=>sc_association-root-text iv_do_root_node_key = /cpd/if_pfp_bo_plan_hdr_c=>sc_node-plan_header_long_text ). *-- Association Key of TEXT->TEXT_CONTENT lv_cont_assoc = lr_frw_conf->get_content_key_mapping( iv_content_cat = /bobf/if_conf_c=>sc_content_ass iv_do_content_key = /bobf/if_txc_c=>sc_association-text-text_content iv_do_root_node_key = /cpd/if_pfp_bo_plan_hdr_c=>sc_node-plan_header_long_text ).
After getting the run-time Node key and Association key, we have to create BO Instances (Records for Root node, Text node, Text_Content node of Dependent BO).
lv_key is the GUID of Financial Plan.
First the Records for Root node is created and its reference is passed to lt_mod along with its Root key, Source key, Node and Association. Then the same is repeated for Text and Text_Content Node.
Get_new_key method is used to generate GUID which will be unique for all BO Instance that we create. After calling the modify method it is always necessary to call Save method to reflect all the changes that we made. Those changes will be reflected in Database. We can also check at lr_message at save and modify method whether particular action is successfully completed or not.
*-- LV_KEY is the GUID of any Financial Plan *-- Details of Dependent Object ROOT Node " Generate New Key lw_root-key = /bobf/cl_frw_factory=>get_new_key( ). lw_root-parent_key = lv_key. lw_root-root_key = lv_key. lw_root-host_bo_key = /cpd/if_pfp_bo_plan_hdr_c=>sc_bo_key. lw_root-host_node_key = /cpd/if_pfp_bo_plan_hdr_c=>sc_node-plan_header. lw_root-host_key = lv_key. lw_root-text_schema_id = 'DEMO'. lw_root-text_exists_ind = abap_true. GET REFERENCE OF lw_root INTO lr_root. *-- The ROOT node and PLAN_HEADER_LONG_TEXT are one and the same. *-- So the Plan Header will act as Source Node as well as Root Node. lw_mod-key = lr_root->key. lw_mod-source_key = lv_key. lw_mod-source_node = /cpd/if_pfp_bo_plan_hdr_c=>sc_node-plan_header. lw_mod-root_key = lv_key. lw_mod-node = /cpd/if_pfp_bo_plan_hdr_c=>sc_node-plan_header_long_text. lw_mod-association = /cpd/if_pfp_bo_plan_hdr_c=>sc_association-plan_header-plan_header_long_text. lw_mod-change_mode = /bobf/if_frw_c=>sc_modify_create. lw_mod-data = lr_root. APPEND lw_mod TO lt_mod. *-- Details of Dependent Object TEXT Node lw_text-key = /bobf/cl_frw_factory=>get_new_key( ). lw_text-root_key = lw_root-key. lw_text-parent_key = lw_root-key. lw_text-user_id_ch = sy-uname. lw_text-language_code = 'EN'. lw_text-text_type = 'DEMO'. lw_text-datetime_ch = sy-datum. lw_text-datetime_cr = sy-datum. GET REFERENCE OF lw_text INTO lr_text. lw_mod-key = lr_text->key. lw_mod-source_key = lw_root-key. lw_mod-source_node = /cpd/if_pfp_bo_plan_hdr_c=>sc_node-plan_header_long_text. lw_mod-root_key = lw_root-key. lw_mod-node = lv_txt_key. “ TEXT Node Key lw_mod-association = lv_txt_assoc. “ ROOT -> TEXT Node Association lw_mod-change_mode = /bobf/if_frw_c=>sc_modify_create. lw_mod-data = lr_text. APPEND lw_mod TO lt_mod. *-- Details of Dependent Object TEXT_CONTENT Node lw_cont-key = /bobf/cl_frw_factory=>get_new_key( ). lw_cont-parent_key = lw_text-key. lw_cont-root_key = lw_root-key. lw_cont-text = 'TEXT_CREATE'. GET REFERENCE OF lw_cont INTO lr_cont. lw_mod-key = lr_cont->key. lw_mod-source_key = lw_text-key. lw_mod-source_node = lv_txt_key. lw_mod-root_key = lw_root-key. lw_mod-node = lv_cont_key. " TEXT_CONTENT Node Key lw_mod-association = lv_cont_assoc. “ TEXT –> TEXT_CONTENT Association lw_mod-change_mode = /bobf/if_frw_c=>sc_modify_create. lw_mod-data = lr_cont. APPEND lw_mod TO lt_mod. *-- Create BO Instance for /BOBF/TEXT_COLLECTION lr_serv_mgr->modify( EXPORTING it_modification = lt_mod IMPORTING eo_change = lr_change eo_message = lr_message ). *-- Save the Transaction to get reflected in DB CLEAR : lr_change, lr_message. lr_tran_mgr->save( IMPORTING eo_change = lr_change eo_message = lr_message ).
This document explains basic concepts to begin work in Business Object Processing Framework. It describes the Delegated node and Dependent BO in detail. The document also elaborates the Class / Methods that are necessary to work with Business Objects. With this understanding readers can explore various options available in BOPF further.