Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

Hi ,

This wiki is helpful to how to modify a entity and save the entity using BOL Programming.

So before Modify the entity , we must lock the entity, so in this article we learn how to lock the entity and how to modify the locked entity using BOL methods.

Please follow the following steps:

  1. Data Declaration
  2. Get the BOL Core Instance
  3. Load the Component set
  4. Create Query Instance
  5. Add Selection Parameters to modify
  6. Get the Result List
  7. Lock and Modify the record
* Data Declaration

data: lr_core type ref to cl_crm_bol_core,
      lr_query type ref to CL_CRM_BOL_DQUERY_SERVICE,
      LR_RESULT TYPE REF TO IF_BOL_ENTITY_COL,
      LR_ENTITY TYPE REF TO cl_crm_bol_entity.
data: LR_CORE type ref toCL_CRM_BOL_CORE,
LR_QUERY type ref to CL_CRM_BOL_DQUERY_SERVICE,
LR_RESULT type ref to  IF_BOL_ENTITY_COL,
LR_ENTITY type ref to CL_CRM_BOL_ENTITY,
LV_TRANSACTION TYPE REF TO if_bol_transaction_context.

* Get the BOL Core instance

lr_core = cl_Crm_bol_core=>get_instance( ).

* Load the component set
LR_CORE->LOAD_COMPONENT_SET( 'BP_APPL' ).

* Create the query instance by passing the search object name
lr_query = CL_CRM_BOL_DQUERY_SERVICE=>get_instance(
iv_query_name = 'BuilEmpAdvancedSearch' ).

* Add the selection parameters
CALL METHOD LR_QUERY->ADD_SELECTION_PARAM
EXPORTING
IV_ATTR_NAME = 'PARTNER'
IV_SIGN      = 'I'
IV_OPTION    = 'EQ'
IV_LOW       = '408697' .

*Get the result list
LR_RESULT = LR_QUERY->GET_QUERY_RESULT( ).

* Get the first object(entity) in the result list
LR_ENTITY ?= LR_RESULT->GET_FIRST( ).

* Lock and modify the property
if  LR_ENTITY->lock( ) = if_genil_Boolean=>true.

*Change the fields
LR_ENTITY->set_property( iv_attr_name = 'BP_NUMBER' iv_value = '408697' ).
LR_ENTITY->set_property( iv_attr_name = 'BIRTHPLACE' iv_value = 'Germany' ).
LR_ENTITY->set_property( iv_attr_name = 'SEARCHTERM1' iv_value = 'EMP 697' ).
LR_ENTITY->set_property( iv_attr_name = 'SEARCHTERM2' iv_value = 'Emp 408' ).
LR_ENTITY->set_property( iv_attr_name = 'EMPLOYER' iv_value = 'Oasis' ).

*Core
LR_CORE->modify( ).
LV_TRANSACTION = lr_core->get_transaction( ).
LV_TRANSACTION->save( ).
LV_TRANSACTION->commit( ).

endif.
  • No labels