Tuesday, 21 August 2012

BOL Create

DATA: lv_bol_core TYPE REF TO cl_crm_bol_core.
*Get the BOL Core instance
lv_bol_core = cl_crm_bol_core=>get_instance( ).
*Load the component set
lv_bol_core->load_component_
set( 'BT' ).

*1.  Build Parameters to create an Entity
*    Here a Order with Technical Name 'BTOrder'
DATA lt_parms TYPE crmt_name_value_pair_tab.
DATA ls_parms TYPE crmt_name_value_pair.

ls_parms-name = 'PROCESS_TYPE'.
ls_parms-value = 'BPAT'.
APPEND ls_parms TO lt_parms.

*2.  Get Factory for Business Object
DATA:lv_order_factory TYPE REF TO cl_crm_bol_entity_factory.
lv_order_factory = lv_bol_core->get_entity_
factory( 'BTOrder' ).

*3.  Create Root Entity
DATA:lv_order TYPE REF TO cl_crm_bol_entity.
lv_order = lv_order_factory->create( lt_parms ).

*4.  Create Child Objects
DATA:lv_order_header TYPE REF TO cl_crm_bol_entity,
     lv_actity_header TYPE REF TO cl_crm_bol_entity.

lv_order_header = lv_order->create_related_
entity( 'BTOrderHeader' ).
lv_actity_header = lv_order->create_related_
entity( 'BTHeaderActivityExt' ).

*5.  Submit Root Objects and Child Objects Which are created
lv_bol_core->modify( ).

*6.  Save and Commit Changes Using Global Tranaction Context
DATA:lv_transaction TYPE REF TO if_bol_transaction_context .
lv_transaction = lv_bol_core->get_transaction( ).
lv_transaction->save( ).
lv_transaction->commit( ).

No comments:

Post a Comment