abapsap-crm

BUT051 table is not updated with BUR_BUPR_BUT051_COLLECT


I'm trying to update DB Table BUT051 by using function module BUR_BUPR_BUT051_COLLECT.

The problem is that it doesn't update at all.

Here's part of my code I'm currently using to update BUT051. Note: The field I'm trying to update is BUT051~PARTNER1.

FORM update_but051.

  "--------------------------------------------------------------------"
  " TABLES
  "--------------------------------------------------------------------"
  DATA: lt_but051 TYPE TABLE OF but051.

  "--------------------------------------------------------------------"
  " STRUCTURES
  "--------------------------------------------------------------------"
  DATA: ls_but051 TYPE but051.

  REFRESH: lt_but051.
  CLEAR: ls_but051.

  " Getting all relationships of the given accounts/partners
  SELECT * FROM but051 INTO TABLE lt_but051 WHERE partner1 IN lt_partners_so.

  " Replacing all partners(field `partner1`) with the master partner.
  ls_but051-partner1 = p_mstcln.
  MODIFY lt_but051 FROM ls_but051 TRANSPORTING partner1 WHERE partner1 <> p_mstcln.

  CLEAR: ls_but051.

  LOOP AT lt_but051 INTO ls_but051.

     CALL FUNCTION 'BUR_BUPR_BUT051_COLLECT'
      EXPORTING
        i_subname = 'BUT051'
        i_but051  = ls_but051.
  ENDLOOP.

  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
      wait = abap_true.

ENDFORM.

Few notes on this code:

Am I using the right function?

Is there another Function Module that does what I want to(updating the field partner1 in but051)?


Solution

  • BUT051 is a table for Business Partner relationships and SAP has a special note for this:

    2594686 - Mass update relationships for BP

    which advises to use the following Function Modules for updating relationships: