Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

This document only describes how to update custom fields in MARC table using BAPI_MATERIAL_SAVEDATA  with an Example. The same process can be followed to update any custom fields in other material related tables.

Steps:

1)  Add the custom field ZZMM_SHELF_LIFE to table MARC using append structure

2)  Extend the standard structure ‘BAPI_TE_MARC’ and ‘BAPI_TE_MARCX’ with the custom field ‘ZZMM_SHELF_LIFE ‘.

3)  The new custom field needs to be added to the field selection group using transaction OMSR. This setting is really important  otherwise the custom field will not get updated though the BAPI returns success message.  You can use transaction OMSR directly or you can navigate through SPRO settings.

4)  After above settings are done, Here is the logic and pseudo code how to update the custom field using BAPI ‘BAPI_MATERIAL_SAVEDATA’.

Define variables:

DATA : wa_extensionin TYPE bapiparex, wa_extensioninx TYPE bapiparexx, it_extensionin TYPE STANDARD TABLE OF bapiparex, it_extensioninx TYPE STANDARD TABLE OF bapiparexx.

DATA: wa_headdata TYPE bapimathead, wa_plantdata TYPE bapi_marc, wa_plantdatax TYPE bapi_marcx, wa_bapi_te_marc TYPE bapi_te_marc, wa_bapi_te_marcx TYPE bapi_te_marcx,

Populate BAPI Structures

wa_headdata-material = wa_marc_update-matnr. “Material

“Number wa_plantdata-plant = „140A‟. “Plant wa_plantdatax-plant = „140A‟. “Plant

Pass custom field ZZMM_SHELF_LIFE value to the structure

wa_bapi_te_marc-plant = „140A‟. “Plant” wa_bapi_te_marc-zzmm_shelf_life = 2000 “Custom Field Value

wa_bapi_te_marcx-plant = „140A‟. “Plant wa_bapi_te_marcx-zzmm_shelf_life = „X‟. “Change Flag

Pass the structure name to the BAPI EXTENSION Structure

wa_extensionin-structure = 'BAPI_TE_MARC'. “Extension

“structure name

“Pass plant value to the offset postion as present in structure 'BAPI_TE_MARC'.”

wa_extensionin-valuepart1+0(4) = wa_bapi_te_marc-plant.

“Pass custom field value to the offset postion as present in structure 'BAPI_TE_MARC'.”

wa_extensionin-valuepart1+25(4) = wa_bapi_te_marc-mm_shelf_life.

APPEND wa_extensionin TO it_extensionin.

wa_extensioninx-structure = 'BAPI_TE_MARCX'. “Extension

“structure name

“Pass plant value to the offset postion as present in structure 'BAPI_TE_MARCX'.”

wa_extensioninx-valuepart1+0(4) = wa_bapi_te_marc-plant.

“Pass custom field change indicator value to the offset postion as present in structure 'BAPI_TE_MARCX'.”

wa_extensioninx-valuepart1+7(1) = wa_bapi_te_marcx-zzmm_shelf_life.

APPEND wa_extensioninx TO it_extensioninx.

Call BAPI to update the data into the data base table MARC

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA' EXPORTING headdata = wa_headdata plantdata = wa_plantdata plantdatax = wa_plantdatax IMPORTING return = wa_return TABLES extensionin = it_extensionin extensioninx = it_extensioninx.

IF wa_return-type CA 'EA'

ROLLBACK WORK.

  1. ELSE. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X'.
  2. ENDIF.
5 Comments
Labels in this area