Application Development 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: 

How to Update Material Number in table standard

jandrivay
Participant
0 Kudos

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.
1 ACCEPTED SOLUTION

former_member1716
Active Contributor

jandrivay,

Recommend you to kindly go through the OSS note 2215852.

Sap has clearly addressed this gap by introducing field ending with _LONG. In the same BAPI you have referred if you get into the header structure and reach down to last field you can find the required field. Below screen shot for reference, try populating the field and your issue will be resolved.

Regards!

5 REPLIES 5

Hi jandrivay,

I think its not possible to update the Material Number. You should copy your existing Material Number to a new Material and set the deletion flag to the old Material Number.

Abinathsiva
Active Contributor
0 Kudos

Hi,

MATNR can be modified only when external number range allowed in material master number range. And changing MATNR in one table (MARA) won't help it flows to multiple areas of system so follow this link Material Number Field Length extension

FredericGirod
Active Contributor

Update the material number length, is not just modifying the value. It is also check all the specific code to be sure you use the correct field size in CALL FUNCTION, in EDI. you did not use the MATN18 ...

Second point, updating the value of the MARA table will have direct impact on all the existing document: Purchase Order, Sales Order, BOM, ... How did you plan to manage this ?

former_member1716
Active Contributor

jandrivay,

Recommend you to kindly go through the OSS note 2215852.

Sap has clearly addressed this gap by introducing field ending with _LONG. In the same BAPI you have referred if you get into the header structure and reach down to last field you can find the required field. Below screen shot for reference, try populating the field and your issue will be resolved.

Regards!

0 Kudos

Thankyou !

it's work !