Tutorial Name

Update custom fields using BAPI extension

Tutorial Description

Update material custom fields using BAPI extension parameter in SAP, update material custom fields using BAPI_MATERIAL_SAVDATA

Tutorial Area Advanced ABAP
Prerequisites ABAP
Learning Level Intermediate
Estimated Time to learn 30
Save to Learning List Save to your Learning List
+ -

Step1:Requirement and basic explanation Important Top^

Requirement:Update MARA custom fields using material BAPI BAPI_MATERIAL_SAVEDATA.

We have some custom fields in MARA table, while creating/updating a material I need update them along with material.

To achieve this, we need to follow below steps:

1.Check for the available structure BAPI_TE_<TABLENAME>, here in this requirement BAPI_TE_MARA, and append custom fields using append structure.

2.Pass the structure and values to material BAPI, BAPI_MATERIAL_SAVEDATA.

Step2:Append structure BAPI_TE_MARA Important Top^

Go to SE11, provide name as BAPI_TE_MARA, display

using BAPI extension for MARA

Click on append structure.

BAPI extension for MARA

A pop up will come, provide a append structure name ex: ZBAPI_MARA_EX, enter

Provide custom fields available in MARA to ZBAPI_MARA_EX.

BAPI extension for MARA

Save and Activate.

Step3:Using extension in BAPI_MATERIAL_SAVEDATA Important Top^

Use the below code to use BAPI extension

  DATA : ls_headdata  TYPE bapimathead,
  ls_clientdata  TYPE bapi_mara,
  ls_clientdatax  TYPE bapi_marax.
  DATA materialdescriptions TYPE TABLE OF bapi_makt .
  DATA : lt_mara TYPE STANDARD TABLE OF bapi_te_mara WITH HEADER LINE,
  lt_marax TYPE STANDARD TABLE OF bapi_te_marax WITH HEADER LINE,
  lt_extensionin TYPE STANDARD TABLE OF  bapiparex WITH HEADER LINE,
  lt_extensioninx TYPE STANDARD TABLE OF bapiparexx WITH HEADER LINE .
  headdata-material = 'TEST_MAT001'.
  headdata-ind_sector = 'M'.
  headdata-matl_type = 'FERT'.
  headdata-basic_view = 'X'.
  clientdata-base_uom = 'EA'.
  clientdatax-base_uom = 'X'.

  wa_mat_desc-langu = 'E'.
  wa_mat_desc-matl_desc = 'Test material description'.
  APPEND wa_mat_desc TO materialdescriptions.
**extension structure
  MOVE 'BAPI_TE_MARA' TO lt_extensionin-structure.
  MOVE headdata-material TO lt_mara-material.
  MOVE 'CUSTOM VALUE' TO lt_mara-ZCUSTOM.
  MOVE lt_mara TO lt_extensionin-valuepart1.
  APPEND lt_extensionin.

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
  EXPORTING
  headdata  = headdata
  clientdata  = clientdata
  clientdatax  = clientdatax
*  PLANTDATA  = PLANTDATA
*  PLANTDATAX  = PLANTDATAX
*  FORECASTPARAMETERS  = FORECASTPARAMETERS
*  FORECASTPARAMETERSX  = FORECASTPARAMETERSX
*  PLANNINGDATA  = PLANNINGDATA
*  PLANNINGDATAX  = PLANNINGDATAX
*  STORAGELOCATIONDATA  = STORAGELOCATIONDATA
*  STORAGELOCATIONDATAX = STORAGELOCATIONDATAX
*  VALUATIONDATA  = VALUATIONDATA
*  VALUATIONDATAX  = VALUATIONDATAX
*  WAREHOUSENUMBERDATA  = WAREHOUSENUMBERDATA
*  WAREHOUSENUMBERDATAX = WAREHOUSENUMBERDATAX
*  SALESDATA  = SALESDATA
*  SALESDATAX  = SALESDATAX
*  STORAGETYPEDATA  = STORAGETYPEDATA
*  STORAGETYPEDATAX  = STORAGETYPEDATAX
*  FLAG_ONLINE  = ' '
*  FLAG_CAD_CALL  = ' '
*  NO_DEQUEUE  = ' '
*  NO_ROLLBACK_WORK  = ' '
  IMPORTING
  return  = ls_return
  TABLES
  materialdescription  = materialdescriptions
*  UNITSOFMEASURE  = UNITSOFMEASURE
*  UNITSOFMEASUREX  = UNITSOFMEASUREX
*  INTERNATIONALARTNOS  = INTERNATIONALARTNOS
*  MATERIALLONGTEXT  = MATERIALLONGTEXT
*  TAXCLASSIFICATIONS  = TAXCLASSIFICATIONS
*  RETURNMESSAGES  = RETURNMESSAGES
*  PRTDATA  = PRTDATA
*  PRTDATAX  = PRTDATAX
  extensionin  = lt_extensionin
  extensioninx  = lt_extensioninx.

Author | Last Updated| | 5 Comments | F Share

Tutorial Comments

Total Comments: Add your Comment
07 Apr 2014

Good tutorial with step by step Update MARA custom fields using material BAPI_MATERIAL_SAVEDATA.realy helpful.good work.

27 May 2015

This is really a good solution.the way you have provided..thank u so much

08 Dec 2015

THE ABOVE CODE IS RESULTING DUMP

08 Dec 2015

THE ABOVE CODE IS RESULTING DUMP

21 Mar 2016

GOOD EXPLANATION. BUT THERE WAS A PROBLEM IN CODING PART FIRST OF ALL SYNTACTICAL ISSUES. BUT THE WAY OF YOUR EXPLANATION IS VERY GOOD.

Leave a Comment

Enter Comment Text