cancel
Showing results for 
Search instead for 
Did you mean: 

Updating a BP marketing attribute on member change.

Former Member
0 Kudos

Hi all,

I am having an issue trying to update a member's marketing attribute upon update. I have read several posts regarding using the FM's listed here, but I have a question with those. The below FM's are the most frequently stated.

FM 'CRM_MKTBP_ASSIGN_ATTRIBUT_TAB' is used to initially assign the marketing attribute set and assign the initial values to the attributes. T

FM 'CRM_MKTBP_UPDATE_ATTR_BP' to update only.

Now, I have taken a look at these FM's and their input values have this attribute set input value:

IV_ATTRIBUTE_SET      TYPE      CRMT_MKTPROF_KEYS-PROFILE_TEMPLATE_ID

Now, IV_ATTRIBUTE_SET has the components:

PROFILE_TEMPLATE_ID         Types    CRMT_PROF_TEMPLATE                  CRM Marketing: Target Group Selection - Attribute Set

PROFILE_ID                                     Types    CRMT_PROFILE_ID                                 CRM Marketing: Profile ID

BP_GUID                            Types    CRMT_TG_BP_GUID                CRM Marketing: Target Group Business Partner GUID

CATCHWORD                                    Types    KLSCHL                                   Keywords

EXCEPTION_FLAG                  Types    CRMT_ISA_MKT_RETURNCODE    Exception Indicator Type CHAR 2

Here is my question. From my research, Target Group Selection and Profile ID are associated with an ALREADY created Target group for marketing. Now, if I ONLY want a BP to be updated with a particular marketing attribute on their master data (without any reference to pre-existing target groups), how would I go about this? In my scenario, PI is calling a zBAPI to update a customer. This BAPI then updates the BP structure with the passed parameters and later commits. Any assistance anyone can provide would be greatly appreciated.

Accepted Solutions (1)

Accepted Solutions (1)

praveen_kumar194
Active Contributor
0 Kudos

i would suggest the  fm ''CRM_MKTBP_SAVE_BP_LIST''

               CLEAR : ls_marketbp,
                            lt_marketbp.
                    ls_marketbp-partner_guid = v_partnerguid.
                    ls_marketbp-partner      = v_partnerid.
                    ls_marketbp-attribute_set = wa_control-zmkt_att_set.
                    ls_marketbp-allocvalues   = lt_market.
                    ls_marketbp-fcode         = 'C'.

                    APPEND ls_marketbp TO lt_marketbp.

                    CLEAR it_return[].
                    CALL FUNCTION 'CRM_MKTBP_SAVE_BP_LIST'
                      EXPORTING
                        iv_msa            = 'X'
                        iv_commit         = ''
                        it_alloclist_bp   = lt_marketbp
                        iv_convert_values = 'X'
                        iv_objtyp         = 'BUT000'
                        iv_set_lock       = 'X'
                        iv_write_ale      = 'X'
                      TABLES
                        et_return         = it_return.

just place a break point in this FM, and just update any value for any attribute on BP manually. you will come to know that exact values will be filled up in the import/export parameters. try to repliace the same in program.

Former Member
0 Kudos

Thanks a lot. I used this logic and was able to create my own function modules to check then create or modify attributes based on existing values! Thanks again! Incase anyone else is curious, my logic is below:

FUNCTION Z_CRM_MKTBP_ATTR.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(IV_MARKETBP) TYPE  CRMT_MKTBP_BP_VALUES
*"     REFERENCE(IV_PARNER_GUID) TYPE  BU_PARTNER_GUID
*"     REFERENCE(IV_PARTNER) TYPE  BU_PARTNER
*"  EXPORTING
*"     REFERENCE(ET_RETURN) TYPE  BAPIRET2_T
*"----------------------------------------------------------------------

   DATA: lt_marketbp TYPE CRMT_MKTBP_BP_VALUES_T,
         ls_marketbp TYPE CRMT_MKTBP_BP_VALUES,
         it_return TYPE BAPIRET2_t,
         v_partnerguid TYPE BU_PARTNER_GUID,
         v_partnerid TYPE BU_PARTNER,
         zmkt_att_set TYPE KLASSE_D,
         lt_market TYPE CRMT_MKTBP_ATTRIBUTE_VALUES_T,
         LT_Partner TYPE TABLE OF CRMT_MKTBP_PARTNER_TAB,
         LS_Partner TYPE CRMT_MKTBP_PARTNER_TAB,
         LT_return TYPE BAPIRET2_t,
         ls_alloc TYPE CRMT_MKTBP_ATTRIBUTE_VALUES,
         lt_alloc TYPE CRMT_MKTBP_ATTRIBUTE_VALUES_T,
         lv_attribute_set TYPE CRMT_MKTPROF_KEYS-PROFILE_TEMPLATE_ID,
         LS_BP_LIST TYPE CRMT_MKTBP_GUID_RANGE,
         LT_BP_LIST TYPE TABLE OF CRMT_MKTBP_GUID_RANGE,
         ls_attr TYPE CRMT_MKTPFCHR_MERK,
         lt_attr TYPE TABLE OF CRMT_MKTPFCHR_MERK,
         LT_ALLOC_BP_LIST TYPE CRMT_MKTBP_ALLOC_BP_TAB,
         LS_ALLOC_BP_LIST TYPE CRMT_MKTBP_ALLOC_BP_LIST.

   CLEAR : ls_marketbp,
           lt_marketbp.

   LS_Partner-PARTNER_GUID  = iv_marketbp-PARTNER_GUID.
   LS_Partner-PARTNER  = iv_marketbp-PARTNER.
   APPEND ls_partner to lt_partner.
   LT_ALLOC = iv_marketbp-allocvalues.
   lv_attribute_set = iv_marketbp-attribute_set.
   READ TABLE lt_alloc into ls_alloc INDEX 1.

* Read list of marketing attributes using FM: CRM_MKTBP_READ_BP_LIST
   ls_BP_list-low = iv_marketbp-PARTNER_GUID.
   APPEND ls_bp_list to lt_bp_list.
   ls_attr-ATNAM = ls_alloc-ATNAME.
   APPEND ls_attr TO lt_attr.

   CALL FUNCTION 'CRM_MKTBP_READ_BP_LIST'
     TABLES
       IT_BP_LIST      = lt_BP_LIST
       ET_RETURN       = lt_return
       ET_BP_ALLOCLIST = LT_ALLOC_BP_LIST
       IT_ATTRIBUTES   = lt_attr.

* If Marketing attribute does not exist, create a new one:
   READ TABLE LT_ALLOC_BP_LIST INTO LS_ALLOC_BP_LIST WITH KEY PROFILE_TEMPLATE_ID = lv_attribute_set.
   IF sy-subrc NE 0.

     READ TABLE lt_alloc into ls_alloc INDEX 1.

     CALL FUNCTION 'CRM_MKTBP_ASSIGN_ATTRIBUT'
       EXPORTING
         IV_ATNAME         = ls_alloc-ATNAME
         IV_ATTRIBUTE_SET  = lv_attribute_set
         IV_MSA            = 'X'
         IV_ATWRT          = ls_alloc-ATWRT
         IV_ATCOD          = '1'
         IV_CONVERT_VALUES = 'x'
         IV_SINGLE_VALUE   = 'x'
         IV_COMMIT         = 'x'
         IV_OBTYP          = 'BUT000'
         IV_WRITE_ALE      = 'x'
       TABLES
         IT_partner        = LT_PARTNER
         ET_RETURN         = LT_return.

     et_return = lt_return.

   ELSE.
* Else update marketing attribute using below logic.

     ls_marketbp-partner_guid  = IV_PARNER_GUID.
     ls_marketbp-partner       = IV_PARTNER.
     ls_marketbp-attribute_set = IV_MARKETBP-attribute_set.
     ls_marketbp-allocvalues   = IV_MARKETBP-allocvalues.
     ls_marketbp-fcode         = 'C'.

     APPEND ls_marketbp TO lt_marketbp.

     CLEAR it_return[].
     CALL FUNCTION 'CRM_MKTBP_SAVE_BP_LIST'
       EXPORTING
         iv_msa            = 'X'
         iv_commit         = ''
         it_alloclist_bp   = lt_marketbp
         iv_convert_values = 'X'
         iv_objtyp         = 'BUT000'
         iv_set_lock       = 'X'
         iv_write_ale      = 'X'
       TABLES
         et_return         = et_return.

   ENDIF.

ENDFUNCTION.

Answers (0)