Create Default Empl relationship while creating BP
Hi ,
This document will help us to keep the default values while creating BP . Here I am keeping the Default relationship of employee responsible Of username.
1. Implement the BADI :- BADI_CRM_BP_UIU_DEFAULTS
2. Write the code in method IF_UIU_BP_DEFAULTS~GET_DEFAULT_VALUES.
Copy and paste the below code .
DATA: lr_typed_context TYPE REF TO cl_bsp_wd_context,
lr_coll_wrapper TYPE REF TO cl_bsp_wd_collection_wrapper,
lr_node TYPE REF TO cl_bsp_wd_context_node,
lr_current TYPE REF TO cl_bsp_wd_value_node,
lr_entity TYPE REF TO cl_crm_bol_entity,
lr_collection TYPE REF TO if_bol_entity_col,
lr_relation TYPE REF TO cl_crm_bol_entity,
ls_relation TYPE crmt_bupa_il_relation,
lv_bp_type TYPE string,
lv_bp_number TYPE string,
lv_emp_res TYPE bu_partner.
FIELD-SYMBOLS: <typed_context> TYPE any,
<context_node> TYPE any.
ASSIGN cr_me->(‘TYPED_CONTEXT’) TO <typed_context>.
IF sy–subrc = 0.
lr_typed_context ?= <typed_context>.
IF lr_typed_context IS BOUND.
ASSIGN lr_typed_context->(‘HEADER’) TO <context_node>.
IF sy–subrc = 0.
TRY.
lr_node ?= <context_node>.
CATCH cx_sy_move_cast_error.
ENDTRY.
IF lr_node IS BOUND.
lr_coll_wrapper ?= lr_node->collection_wrapper.
IF lr_coll_wrapper IS BOUND.
TRY.
lr_entity ?= lr_coll_wrapper->get_current( ).
CHECK lr_entity IS BOUND.
lr_entity->get_property_as_value( EXPORTING iv_attr_name = ‘BP_CATEGORY’
IMPORTING ev_result = lv_bp_type ).
lr_entity->get_property_as_value( EXPORTING iv_attr_name = ‘BP_NUMBER’
IMPORTING ev_result = lv_bp_number ).
lr_collection = lr_entity->get_related_entities( iv_relation_name =‘BuilRelationshipRel’).
IF lr_collection IS BOUND AND lr_collection->size( ) = 0 AND lv_bp_type = ‘1’.
lr_relation = lr_entity->create_related_entity( iv_relation_name =‘BuilRelationshipRel’ ).
CALL FUNCTION ‘CRM_ERMS_FIND_BP_FOR_USER’
EXPORTING
iv_user_id = sy–uname
IMPORTING
ev_bupa_no = lv_emp_res.
ls_relation–partner1 = lv_bp_number.
ls_relation–partner2 = lv_emp_res.
ls_relation–relationshipcategory = ‘BUR011’.
lr_relation->set_properties( EXPORTING is_attributes = ls_relation ).
ENDIF.
CATCH cx_sy_move_cast_error.
CATCH cx_crm_cic_parameter_error.
ENDTRY.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
Hi, I am facing an issue in below stmt where lr_entity is always initial. Can you pls suggest.
lr_entity ?= lr_coll_wrapper->get_current( ).