2

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:

  • Variable p_mstcln is a parameter of type c(10), this is the new partner number.
  • Internal Table lt_partners_so is a table of partners all of which need to be replaced by p_mstcln in but051.

Am I using the right function?

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

Suncatcher
  • 10,355
  • 10
  • 52
  • 90
Diego
  • 133
  • 1
  • 12
  • 4
    Have you looked inside the FM you’re calling? It does not update or insert anything to the database. I don’t know what the right method is to update that table, but this FM is not it. – Bryan Cain Mar 11 '21 at 18:39
  • @BryanCain I did not look inside the function. But I found a question on the SAP forum which tells that this is the function to update table `BUT051`. Do you happen to know what function should I use? – Diego Mar 12 '21 at 07:57
  • 1
    package BUPA has a number of function modules that might help you. BAPI_BUPR_CONTP_CHANGE sounds like it might be what you're looking for. There are others to delete or create relationships between partners as well. – Dirk Trilsbeek Mar 12 '21 at 08:07

1 Answers1

5

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:

  • BAPI_BUPR_RELATIONSHIP_CHANGE
  • BAPI_BUPR_RELATIONSHIP_CREATE
  • BAPI_BUPR_RELATIONSHIP_DELETE
  • BAPI_BUPR_RELATIONSHIP_GET
  • BAPI_BUPR_RELATIONSHIP_REMOVE
  • BAPI_BUPR_RELSHIP_CHECKEXIST
  • BAPI_BUPR_RELSHIP_GET_DETAIL
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Suncatcher
  • 10,355
  • 10
  • 52
  • 90