cancel
Showing results for 
Search instead for 
Did you mean: 

How to add a new partner to a Marketing Campaign

former_member259099
Participant
0 Kudos

Hi, I m trying to add new partner to the parties involved..

i m using CLASS: CL_CRM_MKTPL_APPL_BASE

and method:  IF_CRM_MKTGS_PAR_DATA_PROVIDER~PARTNER_CREATE but we cant do it!!!

DATA : LO_PARTNER TYPE REF TO CL_CRM_MKTPL_APPL_BASE .

        LO_PARTNER = CL_CRM_MKTPL_APPL_BASE=>GET_INSTANCE( ).

        CHECK LO_PARTNER IS BOUND.

        LO_PARTNER->PARTNER_CREATE(

         EXPORTING

            IV_GUID            = LV_GUID

            IT_PARTNER         = LT_PARTNERS

            IV_SUPPRESS_PARDET = LV_SUPPRESS_PARDET

         IMPORTING

            EV_ERROR_OCCURED   = LV_ERROR_OCCURED

            ET_MESSAGES        = LT_MESSAGES ).

        IF sy-subrc = 0.

          CALL METHOD LO_PARTNER->save

            EXCEPTIONS

              failed = 1

              OTHERS = 2

please help!!!

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Aydin,

Please provide the solution for the above requirement?

Thanks,

Mayank

pallavi_an
Participant
0 Kudos

Hi Uyar,

After u do lo_partner->save call method lo_partner->commit.

It will be created.

Regards,

Pallavi

former_member259099
Participant
0 Kudos

We tried to give save and then commit at the end of code.

But again can not insert the partner to the parties involved.

This campaign class little bit different than standart order document structure...

even i couldnt debug the save moment at campaign.

LS_PARTNERS-EXTERNAL_PARTNER_NUMBER = LT_PARTNER-PARTNER.

      LS_PARTNERS-PARTNER_FCT             = 'Z0000002'.

      LS_PARTNERS-REF_PARTNER_FCT         = 'Z0000002'.

      APPEND LS_PARTNERS TO LT_PARTNERS.

      LO_PARTNER = CL_CRM_MKTPL_APPL_BASE=>GET_INSTANCE( ).

      CHECK LO_PARTNER IS BOUND.

      LO_PARTNER->PARTNER_CREATE(

       EXPORTING

          IV_GUID            = LV_GUID

          IT_PARTNER         = LT_PARTNERS

          IV_SUPPRESS_PARDET = LV_SUPPRESS_PARDET

       IMPORTING

          EV_ERROR_OCCURED   = LV_ERROR_OCCURED

ET_MESSAGES        = LT_MESSAGES ).

      IF sy-subrc = 0.

        CALL METHOD LO_PARTNER->SAVE

          EXCEPTIONS

            failed = 1

            OTHERS = 2.

        IF SY-SUBRC EQ 0.

          CALL METHOD LO_PARTNER->COMMIT.

        ENDIF.

Former Member
0 Kudos

Hi,

Hope this helps

    DATA : lr_appl_base TYPE REF TO cl_crm_mktpl_appl_base.

  cl_crm_mktpl_appl_base=>get_instance(
                RECEIVING
                     re_instance = lr_appl_base
                EXCEPTIONS
                     failed      = 1
                OTHERS      = 2 ).

  lr_appl_base->partner_assign_create(
                  EXPORTING
                    im_mktelement_guid = lv_ag_guid_16            "Marketing GUID
                    im_partner         = lit_partner_func_set           "partner function and partner
                    im_suppress_pardet = crmkc_true
                  EXCEPTIONS
                    create_failed      = 1
                    OTHERS             = 2 ).


        IF sy-subrc EQ 0.
        ENDIF.


*For saving and commiting changes.
        CALL METHOD lr_appl_base->save_and_commit
          RECEIVING
            rv_failed = lv_err.

Regards,

Susanta

Former Member
0 Kudos

Hi Aydin,

We are also facing same issue.

Please explain us how you solved the issue.

Thanks,

Manasa Veena P

Former Member
0 Kudos

Hi All,

My issue has been resolved using BOL programming.

Regards,

Manasa Veena P.

Former Member
0 Kudos

Hi Veena,

We also have the same requirement. Can you please let us know the BOL code which you have written to achieve.

I am not able to figure it out.

Thanks,

Mayank

Former Member
0 Kudos

Hello Mayank,

Check the below link

Regards

Manasa.

Former Member
0 Kudos

Hi Manasa,

Thanks for your code. I will check and will come back to you.

Thanks again,

Mayank.

Former Member
0 Kudos

Hi Manasa,

I am getting the error in line:

lr_part_entity = lr_partset_entity->create_related_entity( 'CPGPartnerRel' ).

lr_part_entity is coming blank.

Can you assist .

Thanks,

Mayank

Former Member
0 Kudos

Hi Mayank,

For me its working fine.LR_PART_ENTITY is getting bound.

Could you paste the code you are using. So that i can check and find what is the exact issue.

Regards

Manasa.

Former Member
0 Kudos

Hi Manasa,

Below is the code:

: lr_bol_core            TYPE REF TO cl_crm_bol_core.

DATA: lr_dquery              TYPE REF TO cl_crm_bol_dquery_service.

DATA: lr_result              TYPE REF TO if_bol_entity_col.

DATA: lr_camp_res_entity     TYPE REF TO cl_crm_bol_entity.

DATA: lr_camp_entity         TYPE REF TO cl_crm_bol_entity.

DATA: lr_partset_entity      TYPE REF TO cl_crm_bol_entity.

DATA: lr_partner_coll         TYPE REF TO if_bol_entity_col.

*DATA: lr_part_set            TYPE REF TO cl_crm_bol_entity.

DATA: lr_part_entity         TYPE REF TO cl_crm_bol_entity.

*DATA: lr_part_h_coll         TYPE REF TO if_bol_entity_col.

DATA: lr_transaction         TYPE REF TO if_bol_transaction_context.

*DATA: lv_locked              TYPE char1.



*DATA: lv_attr_struct   TYPE REF TO data.

*FIELD-SYMBOLS: <attrs> TYPE any.


lr_bol_core
= cl_crm_bol_core=>get_instance( ).

TRY.

    lr_bol_core
->start_up( 'CRMD_MKTPL' ).

 
CATCH cx_crm_genil_general_error.

ENDTRY.

*lr_transaction = lr_bol_core->get_transaction( ).


TRY.

    lr_dquery
= cl_crm_bol_dquery_service=>get_instance(

                    
'CampaignAdvSearch' ).

 
CATCH cx_crm_unsupported_object.

ENDTRY.

CALL METHOD lr_dquery->add_selection_param

 
EXPORTING

    iv_attr_name
= 'EXTERNAL_ID'

    iv_sign     
= 'I'

    iv_option   
= 'EQ'

    iv_low      
= 'U-00XXXXXX' .

lr_result
= lr_dquery->get_query_result( ).

IF lr_result IS BOUND.

 
"Get the CPGPartnerSetRel.

  lr_camp_res_entity
= lr_result->get_current( ).

 
IF lr_camp_res_entity IS BOUND.

   
TRY.

       
CALL METHOD lr_camp_res_entity->get_related_entity

         
EXPORTING

            iv_relation_name
= 'Campaign' " CPGPartnerSetRel'

          RECEIVING

            rv_result       
= lr_camp_entity.

       
IF lr_camp_entity IS BOUND.

         
CALL METHOD lr_camp_entity->get_related_entity

           
EXPORTING

              iv_relation_name
= 'CPGPartnerSetRel' "CPGPartnerRel'

            RECEIVING

              rv_result       
= lr_partset_entity.

         
IF lr_partset_entity IS BOUND.

           
CALL METHOD lr_partset_entity->get_related_entities

             
EXPORTING

                iv_relation_name
= 'CPGPartnerRel' "CPGPartnerRel'

              RECEIVING

                rv_result       
= lr_partner_coll.

           
IF lr_partner_coll IS BOUND.

              lr_part_entity
=

lr_partset_entity
->create_related_entity( 'CPGPartnerRel' ).

             
IF lr_part_entity IS BOUND.

               
CALL METHOD lr_part_entity->set_property

                 
EXPORTING

                    iv_attr_name
= 'PARTNER_NO'

                    iv_value    
= '9XXXXX'.

               
CALL METHOD lr_part_entity->set_property

                 
EXPORTING

                    iv_attr_name
= 'PARTNER_FCT'

                    iv_value    
= 'ZCXXXX'.

             
ENDIF.

              lr_bol_core
->modify( ).

             
IF lr_camp_entity->is_locked( ) = abap_true.

                lr_transaction
= lr_part_entity->get_transaction( ).
             
ENDIF.
             
TRY.
                 
IF lr_transaction->check_save_possible( ) = abap_true.
                   
IF lr_transaction->save( ) = abap_true.
                      lr_transaction
->commit( ).
                   
ELSE.
                      lr_transaction
->rollback( ).
                   
ENDIF.
                 
ENDIF.
             
ENDTRY.
           
ENDIF.
         
ENDIF.
       
ENDIF.
     
CATCH cx_crm_genil_model_error .
   
ENDTRY.
 
ENDIF.
ENDIF.

I have copy the same code except the partner function and partner and Campaign id i have changed..

Can it be the authorization issue??

or there is may be a problem with campaign?

Former Member
0 Kudos

Hi Manasa,

Thanks, the code works!!!, The problem is with the Campaign. It has the status rejected. Therefore not able to create i assume.

Thanks for the tremendous help!!

Mayank