Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BAPI_MATERIAL_SAVEREPLICA Unable to update field MARA-SERIAL using the BAPI

Former Member
0 Likes
6,703

Hello Guru's

I am creating a conversion program for material master, I am creating materials using BAPI_MATERIAL_SAVEREPLICA.

In our project we have EWM that means we have WM execution view for materials.

Bapi is unable to update field mara-serial in the data base.

I am passing all the values which are required to update this field.

I am population CLIENTDATA and CLIENTDATAX but still no success.

I also tried this with BAPI_MATERIAL_SAVEDATA but no sucess..

Please help me to resolve this issue.

Regards

Aashish Razdan

Hello Guru's

I am creating a conversion program for material master, I am creating materials using BAPI_MATERIAL_SAVEREPLICA.

In our project we have EWM that means we have WM execution view for materials.

Bapi is unable to update field mara-serial in the data base.

I am passing all the values which are required to update this field.

I am population CLIENTDATA and CLIENTDATAX but still no success.

I also tried this with BAPI_MATERIAL_SAVEDATA but no sucess..

Please help me to resolve this issue.

Regards

Aashish Razdan

11 REPLIES 11
Read only

arivazhagan_sivasamy
Active Contributor
0 Likes
3,910

Hi Aashish,

Update the following fields like below.

CLIENTDATA-SERIAL_NUMBER_PROFILE = 'VALUE'.

CLIENTDATAX-SERIAL_NUMBER_PROFILE = 'X'.

Arivazhagan S

Read only

0 Likes
3,910

I have done that but it is not working

Read only

0 Likes
3,910

Please check the value of

CLIENTDATA-SERIAL_NUMBER_PROFILE = 'VALUE'.


This value should be already maintained value.


Please check the value in  MARA thro F4 help for serial field.


Arivazhagan S

Read only

former_member187748
Active Contributor
0 Likes
3,910

Hi Aashish,

have you used BAPI_TRANSACTION_COMMIT,

after using BAPI_MATERIAL_SAVEREPLICA

to commit the changes you have done.

Please also do ENQUEUE...........and DEQUEUE functionality.

Read only

0 Likes
3,910

Yes I am doing this as well

Read only

Former Member
0 Likes
3,910

Go To Table PLANTDATA ( Type BAPIE1MARC ) and set the flag WAREHOUSE_VIEW = 'X'.

you will have to pass Plant also in that table.

this will help.

Gaurav

Read only

0 Likes
3,910

Hey Gaurav

I have done this as well but no success.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
3,910

Did you get any error message in RETURN parameter after the call of the BAPI and of BAPI_TRANSACTION_COMMIT, also are you able to change this value thru MM02 ?

Regards,

Raymond

Read only

0 Likes
3,910

Hey Raymond BAPI is giving successful message " No Changes done".

And yes I am able to do it using MM02.

Read only

former_member226419
Contributor
0 Likes
3,910

Hi,

Code pls?

BR

Sumeet

Read only

0 Likes
3,910

Populating BAPI structure

METHOD fill_warehouseview.

*  IF gs_bapiwarehousenumberdata IS NOT INITIAL.

   gs_bapiwarehousenumberdata-function = zop_cl_constants=>gc_ins.

   gs_bapiwarehousenumberdatax-function = zop_cl_constants=>gc_ins.

* Material Number

   gs_bapiwarehousenumberdata-material = is_warehouseview-matnr.

   gs_bapiwarehousenumberdatax-material = is_warehouseview-matnr.

* Warehouse Number / Warehouse Complex

   gs_bapiwarehousenumberdata-whse_no = is_warehouseview-lgnum.

   gs_bapiwarehousenumberdatax-whse_no = is_warehouseview-lgnum.

*  ENDIF.

* Fill marc/mara details

   IF is_warehouseview-sernp IS NOT INITIAL.

*    gs_bapiplantdata-serno_prof = is_warehouseview-sernp.

*    gs_bapiplantdatax-serno_prof = zop_cl_constants=>gc_x.

     gs_bapiclientdata-serial_number_profile = is_warehouseview-sernp.

     gs_bapiclientdatax-serial_number_profile = zop_cl_constants=>gc_x.

   ENDIF.

   gs_bapiplantdata-function = zop_cl_constants=>gc_ins.

   gs_bapiplantdatax-function = zop_cl_constants=>gc_ins.

   gs_bapiplantdata-material = is_warehouseview-matnr.

   gs_bapiplantdatax-material = is_warehouseview-matnr.

   IF is_warehouseview-werks IS NOT INITIAL.

     gs_bapiplantdata-plant = is_warehouseview-werks.

     gs_bapiplantdatax-plant = is_warehouseview-werks.

   ENDIF.

   gs_bapiclientdata-function  = zop_cl_constants=>gc_ins.

   gs_bapiclientdatax-function = zop_cl_constants=>gc_ins.

   gs_bapiclientdata-material  = is_warehouseview-matnr.

   gs_bapiclientdatax-material = is_warehouseview-matnr.

ENDMETHOD.


Call to BAPI

*&--------------------------------------------------------------*

*&  METHOD Call Bapi

*&--------------------------------------------------------------*

*& In this method populate the data into the structures of the

*& header and respective views and call the Bapi for posting of data

*& into the system.

*&--------------------------------------------------------------*

METHOD call_bapi.

   DATA:

      ls_return_tmp               TYPE bapiret2,         " Temp work area for bapi return structure.

      ls_return                   TYPE  bapiret2.        " Work area for Bapi return

   DATA:

     lt_headerdata            TYPE STANDARD TABLE OF  bapie1matheader" Header table for Bapi

     lt_clientdata            TYPE STANDARD TABLE OF  bapie1mara,       " Client data

     lt_clientdatax           TYPE STANDARD TABLE OF  bapie1marax ,     " check box stru for mara

     lt_materialdescription   TYPE STANDARD TABLE OF  bapie1makt,       " Material description

     lt_unitsofmeasure        TYPE STANDARD TABLE OF  bapie1marm,       " Unit of measure

     lt_unitsofmeasurex       TYPE STANDARD TABLE OF  bapie1marmx,      " check box for UOM

     lt_internationalartnos   TYPE STANDARD TABLE OF  bapie1mean,       " International Article Numbers (EANs)

     lt_plantdata             TYPE STANDARD TABLE OF  bapie1marc,       " Plant data

     lt_plantdatax            TYPE STANDARD TABLE OF  bapie1marcx ,     " Check box for plant data

     lt_taxclassifications    TYPE STANDARD TABLE OF  bapie1mlan,       " Tax classificayions

     lt_storagelocationdata   TYPE STANDARD TABLE OF  bapie1mard,       " Storage location

     lt_storagelocationdatax  TYPE STANDARD TABLE OF  bapie1mardx,      " check box for storage loc.

     lt_salesdata             TYPE STANDARD TABLE OF  bapie1mvke,       " Sales data

     lt_salesdatax            TYPE STANDARD TABLE OF  bapie1mvkex,      " sales data check box.

     lt_storagetypedata       TYPE STANDARD TABLE OF  bapie1mlgt,       " Storage type

     lt_storagetypedatax      TYPE STANDARD TABLE OF  bapie1mlgtx,      " check box for storage type

     lt_forecastparameters    TYPE STANDARD TABLE OF  bapie1mpop,       " Forcast

     lt_forecastparametersx   TYPE STANDARD TABLE OF  bapie1mpopx,

     lt_planningdata          TYPE STANDARD TABLE OF  bapie1mpgd,       " Planning

     lt_planningdatax         TYPE STANDARD TABLE OF  bapie1mpgdx,

     lt_valuationdata         TYPE STANDARD TABLE OF  bapie1mbew,       " Valuation data

     lt_valuationdatax        TYPE STANDARD TABLE OF  bapie1mbewx,      " Check box for valuation

     lt_warehousenumberdata   TYPE STANDARD TABLE OF  bapie1mlgn,       " warehouse data

     lt_warehousenumberdatax  TYPE STANDARD TABLE OF  bapie1mlgnx,      " Check box for warehouse

     lt_returnmessages        TYPE bapiret2_t.                          " Bapi mesages

   CLEAR: ev_errmsg, ev_errtype.

* Append header data

   APPEND  gs_bapiheaderdata         TO lt_headerdata.

* Append client data

   IF gs_bapiclientdata IS NOT INITIAL.

     APPEND  gs_bapiclientdata         TO lt_clientdata.

     APPEND  gs_bapiclientdatax TO lt_clientdatax.

   ENDIF.

* Append plant data

   IF gs_bapiplantdata IS NOT INITIAL.

     APPEND  gs_bapiplantdata TO lt_plantdata.

     APPEND  gs_bapiplantdatax TO lt_plantdatax.

   ENDIF.

*  Append UOM

   IF gs_bapiunitsofmeasure IS NOT INITIAL.

     APPEND  gs_bapiunitsofmeasure TO lt_unitsofmeasure.

     APPEND  gs_bapiunitsofmeasurex TO lt_unitsofmeasurex.

   ENDIF.

   IF lt_internationalartnos IS NOT INITIAL.

     APPEND  gs_bapiinternationalartnos TO lt_internationalartnos.

   ENDIF.

   IF gs_bapitaxclassifications IS NOT INITIAL.

     APPEND  gs_bapitaxclassifications TO lt_taxclassifications.

   ENDIF.

* Material description

   IF gs_bapimaterialdescription IS NOT INITIAL.

     APPEND  gs_bapimaterialdescription TO lt_materialdescription.

   ENDIF.

   IF gs_bapistoragelocationdata IS NOT INITIAL.

     APPEND  gs_bapistoragelocationdata TO lt_storagelocationdata.

     APPEND  gs_bapistoragelocationdatax TO lt_storagelocationdatax.

   ENDIF.

* Sales data

   IF gs_bapisalesdata IS NOT INITIAL.

     APPEND gs_bapisalesdata             TO lt_salesdata.

     APPEND gs_bapisalesdatax         TO lt_salesdatax.

   ENDIF.

   IF gs_bapistoragetypedata IS NOT INITIAL.

     APPEND   gs_bapistoragetypedata       TO lt_storagetypedata.

     APPEND   gs_bapistoragetypedatax      TO lt_storagetypedatax.

   ENDIF.

   IF gs_bapiforecastparameters IS NOT INITIAL.

     APPEND   gs_bapiforecastparameters    TO lt_forecastparameters.

     APPEND   gs_bapiforecastparametersx   TO lt_forecastparametersx.

   ENDIF.

   IF  gs_bapiplanningdata IS NOT INITIAL.

     APPEND   gs_bapiplanningdata          TO lt_planningdata.

     APPEND   gs_bapiplanningdatax         TO lt_planningdatax.

   ENDIF.

* Valuation data

   IF gs_bapivaluationdata IS NOT INITIAL.

     APPEND   gs_bapivaluationdata         TO lt_valuationdata.

     APPEND   gs_bapivaluationdatax       TO lt_valuationdatax.

   ENDIF.

* Warehouse data

   IF gs_bapiwarehousenumberdata IS NOT INITIAL.

     APPEND   gs_bapiwarehousenumberdata   TO lt_warehousenumberdata.

     APPEND   gs_bapiwarehousenumberdatax  TO lt_warehousenumberdatax.

   ENDIF.

* Call Bapi for creation of Material and extension of the views

   CALL FUNCTION 'BAPI_MATERIAL_SAVEREPLICA'

     EXPORTING

       noappllog            = zop_cl_constants=>gc_x

       nochangedoc          = zop_cl_constants=>gc_x

       testrun              = iv_simulate

       inpfldcheck          = space

     IMPORTING

       return               = ls_return

     TABLES

       headdata             = lt_headerdata

       clientdata           = lt_clientdata

       clientdatax          = lt_clientdatax

       plantdata            = lt_plantdata

       plantdatax           = lt_plantdatax

       forecastparameters   = lt_forecastparameters

       forecastparametersx  = lt_forecastparametersx

       planningdata         = lt_planningdata

       planningdatax        = lt_planningdatax

       storagelocationdata  = lt_storagelocationdata

       storagelocationdatax = lt_storagelocationdatax

       valuationdata        = lt_valuationdata

       valuationdatax       = lt_valuationdatax

       warehousenumberdata  = lt_warehousenumberdata

       warehousenumberdatax = lt_warehousenumberdatax

       salesdata            = lt_salesdata

       salesdatax           = lt_salesdatax

       storagetypedata      = lt_storagetypedata

       storagetypedatax     = lt_storagetypedatax

       materialdescription  = lt_materialdescription

       unitsofmeasure       = lt_unitsofmeasure

       unitsofmeasurex      = lt_unitsofmeasurex

       internationalartnos  = lt_internationalartnos

       taxclassifications   = lt_taxclassifications

       returnmessages       = lt_returnmessages.

* Check the message type for the success or error count.

   IF ls_return-type CA zop_cl_constants=>gc_ae.

     ev_errmsg = ls_return-message.

     ev_errtype = ls_return-type.

   ELSE.

* Commit work done only in case of actual run

     IF iv_simulate IS INITIAL.

       CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

         EXPORTING

           wait = zop_cl_constants=>gc_x.

     ENDIF.

   ENDIF.

* Loop the return message table for bapi messages

   LOOP AT lt_returnmessages INTO ls_return_tmp

     WHERE type CA zop_cl_constants=>gc_ae .

     IF ev_errmsg IS INITIAL.

       ev_errmsg = ls_return_tmp-message.

     ELSE.

       CONCATENATE ev_errmsg

                   ls_return_tmp-message

              INTO ev_errmsg

         SEPARATED BY zop_cl_constants=>gc_comma.

     ENDIF.

   ENDLOOP.

* Return message type S for successful run of Bapi.

   IF ev_errmsg IS INITIAL.

     ev_errtype = zop_cl_constants=>gc_s.

   ENDIF.

* Refresh all the tables after the execution of data.

   REFRESH:

   lt_clientdata, lt_clientdatax,

   lt_unitsofmeasure, lt_unitsofmeasurex,

   lt_materialdescription,

   lt_plantdata, lt_plantdatax,

   lt_salesdata, lt_salesdatax,

   lt_storagelocationdata, lt_storagelocationdatax,

   lt_planningdata, lt_planningdatax,

   lt_warehousenumberdata, lt_warehousenumberdatax,

   lt_valuationdata, lt_valuationdatax,

   lt_storagetypedata, lt_storagetypedatax,

   lt_forecastparameters, lt_forecastparametersx.

   CLEAR:

   gs_bapiclientdata, gs_bapiclientdatax,

   gs_bapiunitsofmeasure, gs_bapiunitsofmeasurex,

   gs_bapimaterialdescription,

gs_bapiplantdata, gs_bapiplantdatax,

gs_bapisalesdata, gs_bapisalesdatax,

gs_bapistoragelocationdata, gs_bapistoragelocationdatax,

gs_bapiplanningdata, gs_bapiplanningdatax,

gs_bapiwarehousenumberdata, gs_bapiwarehousenumberdatax,

gs_bapivaluationdata, gs_bapivaluationdatax,

gs_bapistoragetypedata, gs_bapistoragetypedatax,

gs_bapiforecastparameters, gs_bapiforecastparametersx.

ENDMETHOD.

Hi Sumeet please find the code.