cancel
Showing results for 
Search instead for 
Did you mean: 

SAP CRM: How to execute marketing campaign using abap

Former Member
0 Kudos

I need execute marketing campaign using abap. what have functional modules to solve the problem?

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member197655
Active Participant
0 Kudos

Hi Mihail,

You can create a campaign using the bapi MKT_ELEMENT_CREATE.

You can create campaign elements using the method 'element_create' of the class 'cl_crm_mktpl_appl_base' followed by the 'save' method and BAPI_TRANSACTION_COMMIT.

Hope you find it useful.

Regards,

Manjeet Singh.

Former Member
0 Kudos

I need to execute a campaign and transfer a target group to communication channel using abap. MKT_ELEMENT_CREATE method only creates campaign.

former_member197655
Active Participant
0 Kudos

Hi Mihail ,

So for that you can use the following code :-

DATA lr_object        TYPE REF TO cl_crm_mktpl_execute_backgr.

CREATE OBJECT lr_object .

CALL METHOD lr_object->execute_background
  EXPORTING
    im_guid = lv_cpg_guid.

Regards,

Manjeet Singh.

Former Member
0 Kudos

I solved the problem as follows:

DATA:

          lv_object_guid      TYPE crmt_jw_object_guid, "Campaign GUID

          lr_bol_core     TYPE REF TO cl_crm_bol_core,

          lr_entity       TYPE REF TO cl_crm_bol_entity,

          ls_param          TYPE crmt_name_value_pair,

          lt_param           TYPE crmt_name_value_pair_tab,

          lr_result      TYPE REF TO if_bol_entity_col,

          lr_tx_manager  TYPE REF TO cl_mktprj_transaction_mgr,

          lr_transaction                TYPE REF TO if_bol_transaction_context

          .

    lr_bol_core = cl_crm_bol_core=>get_instance( ).

     lr_bol_core->load_component_set( 'CRMD_MKTPL' ).

     TRY .

         lr_bol_core->get_root_entity(

             EXPORTING

                iv_object_name           = 'Campaign'

                iv_object_guid           = lv_object_guid

             RECEIVING

                rv_result                lr_entity   " Entity

                ).

       CATCH cx_root.

     ENDTRY.

     IF lr_entity IS BOUND.

*   Set JOB_START_TYPE

       CLEAR ls_param.

       ls_param-name  = 'JOB_START_TYPE'.

       ls_param-value = 'I'.

       APPEND ls_param TO lt_param.

       CLEAR ls_param.

       ls_param-name  = 'JOB_NAME'.

       ls_param-value = lv_object_guid.

       APPEND ls_param TO lt_param.

*   Set START_DATE

       CLEAR ls_param.

       ls_param-name  = 'START_DATE'.

       ls_param-value = sy-datlo.

       APPEND ls_param TO lt_param.

*   Set START_TIME

       CLEAR ls_param.

       ls_param-name  = 'START_TIME'.

       ls_param-value = sy-timlo.

       APPEND ls_param TO lt_param.

*       Only continue if root entity could be locked

       IF lr_entity->lock( ) = abap_true.

         TRY.

* get transaction

               lr_transaction = lr_bol_core->get_transaction( ).

*             Call Execute method.

             lr_result = lr_entity->execute( iv_method_name = 'CPGExecuteBackground'

                                                  it_param       = lt_param  ).

*             Save if action has been successful

             lr_tx_manager = cl_mktprj_transaction_mgr=>get_instance( ).

IF lr_tx_manager->save_all( iv_external_commit = abap_true ) = abap_false.   "no success returned

ELSE.

"we can check the status of execution:

"               lr_collection = lr_entity->get_related_entities( iv_relation_name = 'CPGSegmentRel' ).

"...............

"...............

"...............

"end check status of execution

               lr_transaction->save( ).

               lr_transaction->commit( ).

ENDIF.

*           Method failed

           CATCH cx_crm_bol_meth_exec_failed.

          ENDTRY.

       ENDIF.

     ENDIF.

   ENDIF.


Best Regards,

Mikhail Cherkasov

http://www.masterdata.ru/en/

mailto: jimice7@gmail.com