Skip to main content

SAP CRM: Create Account using BOL

Submitted by Stefan Barsuhn on

To create an account in CRM using BOL, proceed as follows:

  " get BOL core ready
  DATA(lr_core) = cl_crm_bol_core=>get_instance( ).
  IF lr_core IS NOT BOUND.
    RAISE EXCEPTION TYPE /iwbep/cx_mgw_tech_exception.
  ENDIF.

  " load component set
  lr_core->load_component_set( 'BP_APPL' ).

  " get customer entity factory
  DATA(lr_factory) = lr_core->get_entity_factory( cl_crm_buil=>header ).
  IF lr_factory IS NOT BOUND.
    RAISE EXCEPTION TYPE /iwbep/cx_mgw_tech_exception.
  ENDIF.

  " set parameters for entity creation - available parameters are
  " all components of structure CRMST_HEADER_OBJECT_BUIL
  DATA(lt_entity_params) = VALUE crmt_name_value_pair_tab( ( name = 'BP_CATEGORY' value = '1' )
                                                           ( name = 'BP_GROUP' value = 'BP' ) ).
  " add further fields to lt_entity_params here. Refer to structure CRMST_HEADER_OBJECT_BUIL for
  " a list of all supported fields

  IF lines( lt_entity_params ) EQ 0.
    RAISE EXCEPTION TYPE /iwbep/cx_mgw_tech_exception.
  ENDIF.

  DATA(lr_entity) = lr_factory->create( lt_entity_params ).
  IF lr_entity IS NOT BOUND.
    RAISE EXCEPTION TYPE /iwbep/cx_mgw_tech_exception.
  ENDIF.

Notes

  • The entity factory calls CL_BUPA_IL_HEADER=>CREATE. Set a breakpoint here to debug the account creation and analyze error messages.
  • Structure CRMST_HEADER_OBJECT_BUIL contains all fields that can be prefilled in the lt_entity_params table (as key - value pairs, where NAME contains the name of the component and VALUE the associated value). The mapping for this is done in CL_CRM_GENIL_ABSTR_COMPONENT=> FILL_STRUCT_FROM_NVP_TAB.
  • Requirement of SAP Standard for creation are only
    • BP_CATEGORY
    • BP_NUMBER (internal number assignment only!)
    • BP_GROUP
    • However, check BADI  BUPA_FURTHER_CHECKS for further checks (required fields) that you may have implemented

 

Tags