Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

BAPI_MATERIAL_SAVEDATA

Hi All ,

I want to update value of Special Procurement type(SOBSK) in costing 1 tab of MM02.I am using Bapi_material_savedata to update this. But it is not getting updated.

I have written some test code for that as follows.

DATA : lwa_headdata TYPE BAPIMATHEAD,

lwa_plantdata TYPE BAPI_MARC,

lwa_plantdatat TYPE BAPI_MARC_GA,

lwa_plantdatax TYPE BAPI_MARCX,

lwa_val TYPE BAPI_MBEW,

lwa_valt TYPE BAPI_MBEW_GA,

lwa_clnt TYPE BAPI_MARA_GA,

lwa_cln TYPE BAPI_MARA,

i_bapi_matreturn2 TYPE TABLE OF bapi_matreturn2.

lwa_headdata-material = '000000000012000041'.

lwa_headdata-COST_VIEW = 'X'.

lwa_plantdata-PLANT = 'ZZ90'.

lwa_plantdata-SPPROCTYPE = '10'.

lwa_plantdatax-PLANT = 'ZZ90'.

lwa_plantdatax-SPPROCTYPE = 'X'.

CALL FUNCTION 'BAPI_MATERIAL_GETALL'

EXPORTING

material = '000000000012000041'

PLANT = 'ZZ90'

IMPORTING

PLANTDATA = lwa_plantdatat

CLIENTDATA = lwa_clnt

VALUATIONDATA = lwa_valt.

MOVE-CORRESPONDING lwa_plantdatat to lwa_plantdata.

MOVE-CORRESPONDING lwa_valt to lwa_val.

MOVE-CORRESPONDING lwa_cln to lwa_clnt.

lwa_headdata-material = '000000000012000041'.

lwa_headdata-IND_SECTOR = 'C'.

lwa_headdata-MATL_TYPE = 'ZSTK'.

lwa_headdata-COST_VIEW = 'X'.

lwa_plantdata-PLANT = 'ZZ90'.

lwa_plantdata-SPPROCTYPE = '20'.

lwa_plantdatax-PLANT = 'ZZ90'.

lwa_plantdatax-SPPROCTYPE = 'X'.

lwa_plantdatax-PROFIT_CTR = 'X'.

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

EXPORTING

headdata = lwa_headdata

CLIENTDATA = lwa_Cln

PLANTDATA = lwa_plantdata

PLANTDATAX = lwa_plantdatax

VALUATIONDATA = lwa_val

TABLES

RETURNMESSAGES = i_bapi_matreturn2[].

IF sy-subrc NE 0.

CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

ELSE.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = space.

ENDIF.

Can u tell if anything is wrong in this??

Thanks ,

Tejas

Tags:
replied

Remove leading zeros in the Material and try that BAPI

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question