Quantcast
Viewing all articles
Browse latest Browse all 9760

Re: Add New Entry in the Marketing Attribute on Saving BP in WEB UI

Hi Holger,

 

My requirement has been changed .Now we do not need to create new entity for Marketing Attributes .Just need to work on Marketing Attributes modification and deletion.Requirement have been finished.

 

Thanks for your help.

 

Sample Code:

 

  METHOD eh_onsave.

 

    DATA: lr_entity          TYPE REF TO cl_crm_bol_entity,

          lt_messages        TYPE crmt_genil_message_tab,

          ls_mkt1            TYPE crmt_mktbp_attribute,

          lt_mkt             TYPE crmt_mktbp_attribute_t,

          lv_partner         TYPE bu_partner,

          lv_bp              TYPE string,

          lv_collection      TYPE REF TO if_bol_bo_col,

          lr_trans1          TYPE REF TO if_bol_transaction_context,

          lv_name            TYPE string,

          lr_view_controller TYPE REF TO cl_bsp_wd_view_controller,

          lr_core1           TYPE REF TO cl_crm_bol_core,

          lr_msg_service1    TYPE REF TO  cl_bsp_wd_message_service.

 

    lr_core1 = cl_crm_bol_core=>get_instance( ).

    lr_entity ?= me->typed_context->builheader->collection_wrapper->get_current( ).

 

    CALL METHOD lr_entity->if_bol_bo_property_access~get_property_as_string

      EXPORTING

        iv_attr_name = 'BP_NUMBER'

      RECEIVING

        rv_result    = lv_bp.

 

    IF lr_entity IS BOUND.

 

      TRY.

          lv_collection = lr_entity->get_related_entities(

                 iv_relation_name = 'BuilMktAttributeRel' iv_mode = 'b' ).

 

        CATCH cx_crm_genil_model_error.

          RETURN.

        CATCH cx_sy_ref_is_initial.

      ENDTRY.

 

      lr_entity ?= lv_collection->get_first( ).

 

      WHILE lr_entity IS BOUND.

        CALL METHOD lr_entity->if_bol_bo_property_access~get_properties

          IMPORTING

            es_attributes = ls_mkt1.

 

        IF ls_mkt1-attribute_set       = 'Z_ROUT_AGENTS' AND

           ls_mkt1-attribute           = 'Z_EXPERIENCE_LEVEL' AND

           ls_mkt1-value               = '001'.

 

          TRY.

              CALL METHOD lr_entity->if_bol_bo_property_access~set_property_as_string

                EXPORTING

                  iv_attr_name = 'VALUE'

                  iv_value     = '002'.

            CATCH cx_sy_conversion_error .

          ENDTRY.

 

        ELSEIF ls_mkt1-attribute_set       = 'Z_ROUT_AGENTS' AND

               ls_mkt1-attribute           = 'Z_EXPERIENCE_LEVEL' AND

               ls_mkt1-value               = '003'.

 

          IF lr_entity->lock( ) = abap_true.

            lr_entity->delete( ).

          ENDIF.

        ENDIF.

 

        APPEND ls_mkt1 TO lt_mkt.

        CLEAR ls_mkt1.

        lr_entity ?= lv_collection->get_next( ).

      ENDWHILE.

 

      lr_core1->modify( ).

      lr_trans1 = lr_core1->get_transaction( ).

      lr_trans1->save( ).

      IF lr_trans1->save( ) = abap_true.

        lr_trans1->commit( abap_true ).

      ENDIF.

 

    ENDIF.

 

    CALL METHOD super->eh_onsave( htmlb_event = htmlb_event

      htmlb_event_ex = htmlb_event_ex ).

  ENDMETHOD.

 

Regards,

Manasa Veena P.


Viewing all articles
Browse latest Browse all 9760

Trending Articles