Which BAPI to use to update ADRC table?

5.1k views Asked by At

Is there any way to write or insert data into ADRC table by using BAPI from outside the SAP?

1

There are 1 answers

0
Suncatcher On

The best candidate for this is BAPI_ADDRESSORG_CHANGE, it can delete/update address records, emails, notes, phones, et cetera.

Code sample (from standard help):

 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.