Skip to Content
0
Aug 10, 2020 at 04:30 AM

How to Update Material Number in table standard

67 Views

Hi all,

Previously, I managed to update the BRGEW field using FM 'BAPI_MATERIAL_SAVEDATA' .
Now, i need to update field MATNR, but can't using this FM because structure Material in BAPIMATHEAD just 18 Lenght,while i need to update more than 18 lenght.is there any way to solve this problem ?

This is my code when update field BRGEW.
DATA : nomor TYPE p DECIMALS 2.
DATA: xheaddata        LIKE bapimathead     OCCURS 0 WITH HEADER LINE,
      xclientdata      LIKE bapi_mara       OCCURS 0 WITH HEADER LINE,
      xclientdatax     LIKE bapi_marax      OCCURS 0 WITH HEADER LINE,
      xunitsofmeasure  LIKE bapi_marm       OCCURS 0 WITH HEADER LINE,
      xunitsofmeasurex LIKE bapi_marmx      OCCURS 0 WITH HEADER LINE,
      xreturn          LIKE bapi_matreturn2      OCCURS 0 WITH HEADER LINE,
      return           LIKE bapiret2 OCCURS 0 WITH HEADER LINE.

PARAMETERS p_matnr LIKE mara-matnr.
PARAMETERS p_brgew TYPE i.

REFRESH xheaddata.
xheaddata-material        = p_matnr. "<= SET MATERIAL NUMBER HERE
xheaddata-basic_view      = 'X'.
xheaddata-inp_fld_check   = 'W'.
APPEND xheaddata.

xclientdata-net_weight    = '111'. "<= SET NET WEIGHT HERE
xclientdatax-net_weight   = 'X'.
xclientdata-unit_of_wt    = 'TO'. "<= SET UNIT OF MEASURE HERE
xclientdatax-unit_of_wt   = 'X'.
APPEND xclientdata.
APPEND xclientdatax.

xunitsofmeasure-gross_wt  = p_brgew. "<= SET GROSS WEIGHT HERE
xunitsofmeasurex-gross_wt = 'X'.
xunitsofmeasure-unit_of_wt = 'TO'. "<= SET UNIT OF MEASURE HERE
xunitsofmeasurex-unit_of_wt = 'X'.
xunitsofmeasure-alt_unit = 'ST'. "<= SET ALT UNIT OF MEASURE HERE
xunitsofmeasurex-alt_unit = 'ST'. "<= SET ALT UNIT OF MEASURE HERE
APPEND xunitsofmeasure. APPEND xunitsofmeasurex.

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
  EXPORTING
    headdata        = xheaddata
    clientdata      = xclientdata
    clientdatax     = xclientdatax
  TABLES
    unitsofmeasure  = xunitsofmeasure
    unitsofmeasurex = xunitsofmeasurex
    returnmessages  = xreturn.
IF sy-subrc = 0.
  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
      wait = 'X'.
  IF return-type = 'S'.
    WRITE : 'Material', p_matnr, 'Berhasil di update',/.
  ELSEIF return-type = 'E'.
    WRITE : 'Gagal',/.
  ENDIF.
ENDIF.