Use BAPI to fill customer field in
material master
1 Contents
1 Contents.........................................................................................................................................1
2 Changes..........................................................................................................................................1
3 System............................................................................................................................................1
4 Description.....................................................................................................................................1
2 Changes
13.06.2020 Version 1.0 Daniel Knapp Basis-Version
3 System
SAP ERP
4 Description
1. It is important to add a field group to the customer field. Without a field group the
BAPI will ignore field changes. Also, a Maintenance Status must be set.
a. Go to Field selection through transaction SPRO: Logistics General -> Material
Master -> Field Selection -> Assign Fields to Field Selection Groups
b. Select the customer field you want to maintain (
) or add it ( ).
c. Set a suitable Maintenance Status. Use F1 help for a list of all allowed values.
13.06.2020 cosnova GmbH Seite 1
d. Field group 90 is the default. If required a custom field group can be created
(starting from 200).
e. Details on the field group can be found by clicking on
Example implementation:
REPORT zdk_test.
DATA: ls_headdata TYPE bapimathead,
ls_plantdata TYPE bapi_marc,
ls_plantdatax TYPE bapi_marcx,
ls_bapi_te_marc TYPE bapi_te_marc,
ls_bapi_te_marcx TYPE bapi_te_marcx,
ls_return TYPE bapiret2,
ls_extensionin TYPE bapiparex,
lt_extensionin TYPE STANDARD TABLE OF bapiparex,
ls_extensioninx TYPE bapiparexx,
lt_extensioninx TYPE STANDARD TABLE OF bapiparexx.
ls_headdata-material = '1236540001'.
ls_plantdata-plant = 'CN01'.
ls_plantdatax-plant = 'CN01'.
ls_bapi_te_marc-plant = ls_plantdata-plant.
ls_bapi_te_marcx-plant = ls_plantdata-plant.
ls_bapi_te_marc-zz_ameversion = '05'.
ls_bapi_te_marcx-zz_ameversion = abap_true.
ls_extensionin-valuepart1 = ls_bapi_te_marc.
ls_extensionin-structure = 'BAPI_TE_MARC'.
ls_extensioninx-valuepart1 = ls_bapi_te_marcx.
ls_extensioninx-structure = 'BAPI_TE_MARCX'.
APPEND ls_extensionin TO lt_extensionin.
APPEND ls_extensioninx TO lt_extensioninx.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = ls_headdata
plantdata = ls_plantdata
plantdatax = ls_plantdatax
IMPORTING
return = ls_return
TABLES
extensionin = lt_extensionin
extensioninx = lt_extensioninx.
IF ls_return-type CA 'EA'.
ROLLBACK WORK.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.
13.06.2020 cosnova GmbH Seite 2
The customer field is maintained through the extensionin / extensioninx tables of the BAPI.
Each line of this table consists of the serialized values (maybe split in parts depending on the
length) and a structure component.
It is recommended to also study the standard function module documentation of these
parameters via transaction SE37.
For each material master table, a “BAPI_TE_*” structure exists (e.g. BAPI_TE_MARA,
BAPI_TE_MARC, …). This also applies to the X-Structures.
Extend the required structure through an append via transaction SE11:
(Required to use Component Type BAPIUPDKZ for the X-Structure components).
Fill the structures as shown in the example code above, supply the
EXTENSIONIN/EXTENSIONINX tables and execute the BAPI.
13.06.2020 cosnova GmbH Seite 3