Skip to Content
0
Feb 01, 2018 at 04:01 PM

CRM BOL Programming to insert new Condition Type with value

192 Views Last edit Feb 02, 2018 at 11:29 AM 2 rev

Hi,

Requirement is to insert a new Condition Type along with rate for a CRM Service Order created via tr code CRMD_ORDER through PROXY .

From the PROXY to create Service Order we have written a BOL code to insert new condition type and rate for each line item to be created .

Here is the code in brief :

lr_core = cl_crm_bol_core=>get_instance( ).

lr_core->start_up('BT'). CHECK lr_core IS BOUND.

lr_entitynew ?= lr_core->get_root_entity( iv_object_name = 'BTOrder' iv_object_guid = ls_header ).

CHECK lr_entitynew IS BOUND.

lr_entitynew = lr_entitynew->get_related_entity( 'BTOrderHeader' ).

lr_entitynew = lr_entitynew->get_related_entity( 'BTHeaderItemsExt' ).

CHECK lr_entitynew IS BOUND.

TRY.

CALL METHOD lr_entitynew->get_related_entities EXPORTING iv_relation_name = 'BTOrderItemAll' RECEIVING rv_result = lr_coll.

CATCH cx_crm_genil_model_error.

ENDTRY.

CHECK lr_coll IS BOUND.

lr_entity = lr_coll->get_first( ).

WHILE lr_entity IS BOUND.

lr_entity = lr_entity->get_related_entity( 'BTItemConditionSet' ). .....................

..........................................................................................................

lr_entity->switch_to_change_mode( ).

IF lr_entity->is_changeable( ) = abap_true. TRY.

lr_entity_zadd = lr_entity->create_related_entity( iv_relation_name = 'BTCondICondLineAll').

CATCH cx_crm_genil_duplicate_rel

CATCH cx_crm_genil_model_error. ENDTRY. ENDIF.

The line in BOLD having lr_entity_zadd getting ZERO reference sometimes when it goes inside a loop for every line item . Is there any issue in the code ?

Although If WAIT statement is added before then lr_entity_zadd getting value .

It would very nice if anyone can provide their valuable feedback .

Regards

Amit