简体   繁体   中英

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:

  • 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 )?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM