Skip to Content
avatar image
Former Member

Issuse in BAPI_MATERIAL_SAVEDATA Update

Hi,

I am trying to update multiple material plant combination to BAPI BAPI_MATERIAL_SAVEDATA and but everytime I pass one material plant it is updating correctly but whenever i send multiple records of material plan combination , it is not updating. I am updating MARC custom field which I have already extended in the respective BAPI structure.

I have pasted code below for reference, please suggest.

Ankesh

WA_DCS-MATNR =  'XX311PBF'.
 WA_DCS-WERKS =   '1040'.
 WA_DCS-ZZDCBNR = '51102103'.
 APPEND WA_DCS TO IT_DCS.

 WA_DCS-MATNR =  'XXF7311PBF'.
 WA_DCS-WERKS =   '1000'.
 WA_DCS-ZZDCBNR = '51102103'.
 APPEND WA_DCS TO IT_DCS.

 WA_DCS-MATNR =  'XXF7311PBF'.
 WA_DCS-WERKS =   '1030'.
 WA_DCS-ZZDCBNR = '51102103'.
 APPEND WA_DCS TO IT_DCS.


 LOOP AT IT_DCS INTO WA_DCS.
   CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT'
     EXPORTING
       INPUT  = WA_DCS-MATNR
     IMPORTING
       OUTPUT = WA_DCS-MATNR.


   WA_EXTENSIONIN-STRUCTURE = 'BAPI_TE_MARC'.
   WA_EXTENSIONIN-VALUEPART1+0(4) = WA_DCS-WERKS.
   WA_EXTENSIONIN-VALUEPART1+4(8) = WA_DCS-ZZDCBNR.
   APPEND WA_EXTENSIONIN TO IT_EXTENSIONIN.

   WA_EXTENSIONINX-STRUCTURE = 'BAPI_TE_MARCX'.
   WA_EXTENSIONINX-VALUEPART1+0(4) = WA_DCS-WERKS.
   WA_EXTENSIONINX-VALUEPART1+4(1) = 'X'.
   APPEND WA_EXTENSIONINX TO IT_EXTENSIONINX.

   WA_HEADDATA-MATERIAL = WA_DCS-MATNR.
   WA_HEADDATA-PURCHASE_VIEW = 'X'.


   AT END OF MATNR.
     CLEAR : WA_RETURN, WA_RETURN1, GV_STRING, GV_STRING1, GV_X.


     CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
       EXPORTING
         HEADDATA     = WA_HEADDATA
       IMPORTING
         RETURN       = WA_RETURN
       TABLES
         EXTENSIONIN  = IT_EXTENSIONIN
         EXTENSIONINX = IT_EXTENSIONINX.

     CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
       IMPORTING
         RETURN = WA_RETURN1.
ENDAT.
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Oct 27, 2015 at 07:03 AM

    Hello Ankesh,

    Did you clear the Work area and Internal tables at the end of the loop as you are using APPEND wa TO itab.

    CLEAR:

    WA_HEADDATA,

    IT_EXTENSIONIN, 

    IT_EXTENSIONINX.

    Regards,

    Thanga

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 27, 2015 at 07:16 AM

    You can add only one plant during one call of the BAPI.

    Add comment
    10|10000 characters needed characters exceeded