Skip to Content

Purpose : Assign and Modify marketing attributes to the Business Partner through the report in SAP-CRM.

Here the source code.

Goto tcode SE38.

DATA : it_f type CRMT_MKTBP_BP_VALUES_T,

       it_1 type TABLE OF CRMT_MKTBP_BP_VALUES,

       it_2 type TABLE OF CRMT_MKTBP_ATTRIBUTE_VALUES,

       wa_1 type CRMT_MKTBP_BP_VALUES,

       wa_2 type CRMT_MKTBP_ATTRIBUTE_VALUES.

DATA : ET_RETURN type TABLE OF BAPIRET2.

wa_2-ATNAME         = ‘HOBBIES’.

*wa_2-ATWRT          = ‘soccer’.

wa_2-ATWRT           = ‘golf’.

APPEND wa_2 to it_2.

wa_2-ATNAME         = ‘FZ_BYKE_SET’.

*wa_2-ATWRT          = ‘childern’.

wa_2-ATWRT          = ‘youngers’.

APPEND wa_2 to it_2.

wa_1-PARTNER_GUID    = ‘005056C000081EE48DE3BD1167EF9685’.

wa_1-PARTNER             = ‘0000423192’.

wa_1-ATTRIBUTE_SET   = ‘INTERESTS’.

wa_1-ALLOCVALUES     = it_2.

append wa_1 to it_1.

wa_1-PARTNER_GUID   = ‘005056C000081EE48DE3BD1167EF9685’.

wa_1-PARTNER            = ‘0000423192’.

wa_1-ATTRIBUTE_SET  = ‘FZ_BYKE_SET’.

wa_1-ALLOCVALUES    = it_2.

append wa_1 to it_1.

CALL FUNCTION ‘CRM_MKTBP_SAVE_BP_LIST’

   EXPORTING

    IV_MSA                              = ‘ ‘

    IV_COMMIT                        = ‘X’

    it_alloclist_bp                      = it_1

    IV_CONVERT_VALUES       = ‘X’

    IV_OBJTYP                         = ‘BUT000’

    IV_SET_LOCK                     = ‘X’

    IV_WRITE_ALE                   = ‘X’

  TABLES

    ET_RETURN                       = ET_RETURN

           .

CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’

  EXPORTING

    WAIT              = ‘X’

*  IMPORTING

*    RETURN        =

           .

IF sy-subrc = 0.

  MESSAGE ‘MARKETING’ ATTRIBUTES SUCCESSFULLY CREATED FOR GIVEN BP’ TYPE ‘S’.

ELSE .

  MESSAGE ‘MARKETING ATTRIBUTES NOT CREATED FOR GIVEN BP’ TYPE ‘E’.

ENDIF.

Before execution.


In the program we are assigning marketing attributes to the business partner number  0000423192.


Go to tcode BP for testing particular business partner.

sp1.JPG

Here, there is no marketing attributes to the existing business partner.

After execution:

Details of bp number 423192 Marketing attributes.

FZ_BYKE_SET is the attribute set name and its attribute is FZ_BYKE_SET and its value is CHILDREN shown in the below screen shot.

sp1.JPG

And INTERESTS is the attribute set name and its attribute is HOBBIES and its value is SOCCER shown in the below screen shot.

sp1.JPG

Finally marketing attributes successfully assigned to particular business partner.

Now If you want to modify the attributes values then go to program change the values in the code. Modified screen shot shown below.

Here value youngers is the modified value to the FZ_BYKE_SET attribute set.



sp1.JPG

And value golf is the modified value to the INTERESTS attribute set.

sp1.JPG

Successfully modified both values of both attribute sets.

To report this post you need to login first.

12 Comments

You must be Logged on to comment or reply to a post.

    1. Siva prasad Ramani Post author

      Yeah Kasi.

      Not only by using this report to get that. You can assign or modify the marketing attributes to existing BP go through SAP Tcodes.

      Below is the way of create/change and assign marketing attributes to existing BP through tcodes.

      tcode CRMD_PROF_TEMPL for creating Attribute Set.

      tcode CRMD_PROF_CHAR for change/create Attributes.

      tcode CRMD_PROF_BP for assigning attribute set to existing BP.

      And finally go to tcode BP enter business partner number and check attribute set, attributes, values and all those stuff assigned or not. Still have any queries let me know. 😎 ..

      Regards,

      Siva R.

      (0) 
  1. Ravi Teja Guptha N

    Hi Shiva,

    Nice Blog!!!!

    I want to add the marketing attribute values instead of overwriting the old ones.

    Is there any way to do that.

    In the given example after executing the second time, i need soccer and golf should be attached to the BP.

    I have checked the above FM using fcode as well, still it is overwriting.

    Thanks,

    Ravi

    (0) 
    1. Siva prasad Ramani Post author

      Hi Ravi Teja,

      Thanks.

      Yes there is way to do that.

      If you want to Add attributes to BP we can use this FM

      CRM_MKTBP_CHANGE_BP and import your bp number guid and fcode etc.. then marketing attribute values will be add with out overwrite unless use this FM it will be overwrite.


      Regards,

      Siva R.

      (0) 
  2. Christian Dr. Drumm

    Hi Siva,

    an alternative solution would be to use the BOL to update the marketing attributes. Once you have a BP-entity you can simply do the following:

    DATA: mktattr_entity TYPE REF TO cl_crm_bol_entity,

               mktattr        TYPE crmt_mktbp_attribute.

    mktattr_entity = bp_entity->create_related_entity( iv_relation_name = |BuilMktAttributeRel| ).

      

        mktattr-attribute_set  = |INTERESTS|.

        mktattr-attribute        = |HOBBIES|

        mktattr-value             = |soccer|.

        mktattr-changed_at    = sy-datum.

        mktattr-changed_by   = sy-uname.

        mktattr_entity->set_properties( mktattr ).

    IMHO this code is easier to read and understand compared to the direct use of the function module. Furthermore, you can use the same code to create marketing attributes in the Web UI as well.

    Best,

    Christian

    (0) 
    1. Siva prasad Ramani Post author

      Yes absolutely Christian. We can assign Marketing attributes through create_related_entity get from Business Object Layer. For web UI purpose.

      But we have plenty of BAPIs right. So i tried to how do we use CRM_MKTBP_SAVE_BP_LIST  BAPI.

      Thank you.

      Siva R.

      (0) 

Leave a Reply