cancel
Showing results for 
Search instead for 
Did you mean: 

Start campaign from ABAP source code

Former Member
0 Kudos

Hello experts!

As it's mentioned in the title I have problem with starting campaign using ABAP source code. I'm using BOL to get to the right entity, but I don't know what I should do next. Below I've pasted my source code. Please help.



DATA: lr_entity       TYPE REF TO cl_crm_bol_entity.

     DATA: lr_entity_rel   TYPE REF TO cl_crm_bol_entity.

     DATA: lr_bol_core     TYPE REF TO cl_crm_bol_core.

     DATA: lr_context      TYPE REF TO if_bol_transaction_context.

     DATA: lv_object_guid  TYPE crmt_object_guid.

     DATA: ls_params       TYPE crmt_name_value_pair.

     DATA: lt_params       TYPE crmt_name_value_pair_tab.

     DATA: lv_temp         TYPE string.

     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           = '00155DB5D0071ED3B9C83DDD1AD3D231'

           RECEIVING

             rv_result                lr_entity   " Entity

         ).

       CATCH cx_root.

     ENDTRY.

     lr_entity ?= lr_entity->get_related_entity( 'CPGStatusRel' ).

     IF lr_entity IS BOUND.

    

       "????

     ENDIF.

     lr_bol_core->modify( ).

     lr_context = lr_entity->get_transaction( ).

     IF lr_context->check_save_needed( ) EQ abap_true.

       lr_context->save( ).

       lr_context->commit( ).

ENDIF.

Thanks in advance

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello Gaurav,

I have set the dates but I still get the same error

Best regards,

Andrew

Former Member
0 Kudos

Hi Andrew,

The report CRM_MKTTGGRP_EXPORT_BATCH is called to execute a campaign and I believe that is what you will have to do in your custom code as well. The selection screen of the report is rather strange so I'd say put a breakpoint and see what values are passed from WUI when you execute a campaign.

Did you manage to set the status of the campaign to released?

Kind regards,

Gaurav

Former Member
0 Kudos

Hello Gaurav,

I would try the suggested solution, but answering to your question, I haven't set the status of the campaign to released yet. Right now I've only created a new campaign, that's all. How can I set its status to released?

Thank you in advance.

Best regards,

Andrew

Former Member
0 Kudos

Hi Andrew,

I am in the middle of a similar work. So in case I figure out a solution I will let you know.

Kind regards,

Gaurav

Former Member
0 Kudos

Ok, thank You

Best regards,

Andrew

Former Member
0 Kudos

Hi Andrew,

Code to set the status to released is below. I also now have to execute the campaign. In case you've already managed to do that do let me know.

Kind regards,

Gaurav

*    ls_param          TYPE crmt_name_value_pair,
*    lt_param           TYPE crmt_name_value_pair_tab,

*    lr_cpg is a handle to the campaign

*    lr_core = cl_crm_bol_core=>get_instance( ).


    CLEAR lt_param.


*   Set ACTIVITY
    CLEAR ls_param.
    ls_param-name  = 'ACTIVITY'.
    ls_param-value = 'CREL'.
    APPEND ls_param TO lt_param.

*   Set USER_STATUS
    CLEAR ls_param.
    ls_param-name  = 'USER_STATUS'.
    ls_param-value = ''.
    APPEND ls_param TO lt_param.

*   Set RESET_STATUS
    CLEAR ls_param.
    ls_param-name  = 'RESET_STATUS'.
    ls_param-value = ''.
    APPEND ls_param TO lt_param.

    lr_cpg->execute( iv_method_name = 'CPGChangeStatus' it_param  = lt_param ).
    lr_core->modify( ).

Former Member
0 Kudos

This is an easy of executing a campaign! Hope it answers your original question.

   *   Set JOB_START_TYPE
    CLEAR ls_param.
    ls_param-name  = 'JOB_START_TYPE'.
    ls_param-value = 'I'.
    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.

    lr_cpg->execute( iv_method_name = 'CPGExecuteBackground' it_param  = lt_param ).
    lr_core->modify( ).

Former Member
0 Kudos

Hello Gaurav,

I did manage to change the status of the campaign using your code. It's now released.

Unfortunatly I still have a problem starting this campaign. When I used your code, I get an error


"A RAISE statement in program "CL_CRM_MKTIB_ACTION_PARAMETERSCP" has raised exception condition "NOT EXISTS".

The error shows after executing this line:


lr_cpg->execute( iv_method_name = 'CPGExecuteBackground' it_param  =lt_param )

Thanks for your help.

Best regards,

Andrew

Former Member
0 Kudos

Hi Andrew,

Did you set the planned start and end dates?

"  date_long         TYPE C LENGTH 10

"Add the dates
    lr_cpg_dates ?= lr_cpg->create_related_entity( iv_relation_name = 'CPGExternalAttributesRel' ).
    IF lr_cpg_dates IS BOUND.
      WRITE sy-datlo TO date_long DD/MM/YYYY.
      date_long_str = date_long.
      lr_cpg_dates->set_property_as_string( iv_attr_name = 'PLANSTARTDATE' iv_value = date_long_str ).
      lr_cpg_dates->set_property_as_string( iv_attr_name = 'PLANFINISHDATE' iv_value = date_long_str ).
    ENDIF.