BAPI Change Material (TCode MM02)

Berikut ini sedikit contoh untuk mengubah material dengan menggunakan BAPI untuk mengubah data volume rebate, material group, dll.

DATA: ls_headdata     LIKE  bapimathead,
      ls_clientdata   LIKE  bapi_mara,
      ls_clientdatax  LIKE  bapi_marax,
      ls_salesdata    LIKE  bapi_mvke,
      ls_salesdatax   LIKE  bapi_mvkex,
      ls_return       LIKE  bapiret2.

CLEAR : ls_headdata, ls_clientdata, ls_clientdatax, ls_salesdata,
        ls_salesdatax, ls_return.

*Struktur  HEADDATA:
ls_headdata-material    = mara-matnr.
ls_headdata-basic_view  = 'X'.
ls_headdata-sales_view  = 'X'.

*Struktur CLIENTDATA
ls_clientdata-old_mat_no = mara-bismt.
ls_clientdata-matl_group = mara-matkl.

*Struktur CLIENTDATAX
ls_clientdatax-old_mat_no = 'X'.
ls_clientdatax-matl_group = 'X'.

*Struktur SALESDATA:
ls_salesdata-sales_org  = mvke-vkorg.
ls_salesdata-distr_chan = mvkv-vtweg.
ls_salesdata-rebate_grp = mvke-bonus.
ls_salesdata-matl_grp_1 = mvke-mvgr1.

*Struktur SALESDATAX:
ls_salesdatax-sales_org  = '1000'.
ls_salesdatax-distr_chan = '00'.
ls_salesdatax-rebate_grp = 'X'.
ls_salesdatax-matl_grp_1 = 'X'.


CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
  EXPORTING
    headdata    = ls_headdata
    clientdata  = ls_clientdata
    clientdatax = ls_clientdatax
    salesdata   = ls_salesdata
    salesdatax  = ls_salesdatax
  IMPORTING
    return      = ls_return.

IF ls_return-type = 'S'.
  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ELSE.
  CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ENDIF.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s