1

ADRC有没有办法使用 SAP 外部的 BAPI将数据写入或插入表中?

4

1 回答 1

1

最好的选择是BAPI_ADDRESSORG_CHANGE,它可以删除/更新地址记录、电子邮件、笔记、电话等。

代码示例(来自标准帮助):

 DATA: objtype    LIKE bapi4001_1-objtype,
       obj_id     LIKE bapi4001_1-objkey,
       obj_id_ext LIKE bapi4001_1-extension,
       context    LIKE bapi4001_1-context,
       address_number LIKE adrc-addrnumber,
       bapiadtel  LIKE bapiadtel OCCURS 0 WITH HEADER LINE,
       bapiadtel_x LIKE bapiadtelx OCCURS 0 WITH HEADER LINE,
       return     LIKE bapiret2 OCCURS 0.

* Assign the following object type and object key to a main customer address
  objtype = 'KNA1'.
  obj_id  = <customer number>.
  obj_id_ext = ' '.
  context = '0001'.

* Get existing data by calling, e.g. FM 'BAPI_ADDRESSORG_GETDETAIL'

* Enter the reference structure data
* The telephone number with serial number '002' is to be deleted and the one with serial number '003' updated

  CLEAR: bapiadtel, bapiadtel_x.
  bapiadtel-consnumber = '002'.
  bapiadtel_x-updateflag = 'D'.
  APPEND: bapiadtel, bapiadtel_x. "Delete entry

  CLEAR: bapiadtel, bapiadtel_x.
  bapiadtel-consnumber = '003'.
  bapiadtel-extension = '77733'.
  bapiadtel_x-extension = 'X'.
  bapiadtel_x-updateflag = 'U'
  APPEND: bapiadtel, bapiadtel_x. "Update entry

  CLEAR: bapiadtel, bapiadtel_x.
  bapiadtel-telephone = '06227'.
  bapiadtel-extension = '11111'.
  bapiadtel_x-updateflag = 'I'.
  APPEND: bapiadtel, bapiadtel_x. "Insert new entry

CALL FUNCTION 'BAPI_ADDRESSORG_CHANGE'
     EXPORTING
          obj_type       = objtype
          obj_id         = obj_id
          obj_id_ext     = obj_id_ext
          context        = context
     IMPORTING
         address_number = address_number
     TABLES
         bapiadtel      = bapiadtel
         bapiadtel_x    = bapiadtel_x
         return         = return.
于 2021-05-05T10:45:52.670 回答