6 Replies Latest reply: Mar 5, 2012 6:10 AM by siddu m RSS

Bapi_material_savedata error

siddu m
Currently Being Moderated

Dear friends,

I am updating the Material Description short text in Material master and I have the following code.  I am not able to update, what am i doing wrong can you please take a look at the code.

 

Thanks.

 

CODE:

REPORT  test.

 

TABLES: MARA,  "General Material Data

        MAKT,  "Material Descriptions

        BAPIRET2.

 

DATA: BAPI_HEAD   LIKE BAPIMATHEAD,

      BAPI_MAKT   LIKE BAPI_MAKT,   

      BAPI_MARA1  LIKE BAPI_MARA.

 

 

DATA: BEGIN OF INT_MAKT OCCURS 0.

        INCLUDE STRUCTURE BAPI_MAKT.

DATA: END OF INT_MAKT.

 

DATA: BEGIN OF INT_update OCCURS 100,

         MATNR(40),   

         WERKS(4),  

         MAKTX(40), 

       END OF INT_update.

 

 

PARAMETERS:  P_WERKS LIKE MARC-WERKS DEFAULT '7000' OBLIGATORY,

       F_FILE LIKE RLGRAP-FILENAME

             DEFAULT 'C:\test.TXT' MEMORY ID F_FILE.

 

PERFORM WSUPLOAD.

PERFORM  GETUPDATE.

 

FORM WSUPLOAD.

call function 'WS_UPLOAD'

  EXPORTING

    FILENAME                      = F_FILE

    FILETYPE                      = 'DAT'

  •   FILETYPE                      = 'WK1'

  tables

    data_tab                      = INT_update

  EXCEPTIONS

    FILE_OPEN_ERROR               = 1.

 

 

ENDFORM.

 

FORM GETUPDATE.

LOOP AT INT_update.

    CLEAR: BAPI_HEAD,

           BAPI_MARA1,

           BAPIRET2.

  • Header

    BAPI_HEAD-MATERIAL        = INT_update-MATNR.

  • BAPI_HEAD-BASIC_VIEW      = 'X'.

 

  • Material Description

    REFRESH INT_MAKT.

    INT_MAKT-MATL_DESC       = INT_update-MAKTX.

    APPEND INT_MAKT.

 

    WRITE:/ BAPI_HEAD.

 

    call function 'BAPI_MATERIAL_SAVEDATA'

      exporting

        HEADDATA                   = BAPI_HEAD

        CLIENTDATA                 = BAPI_MARA1

  •       CLIENTDATAX                = BAPI_MARAX

  •       PLANTDATA                  = BAPI_MARC1

      IMPORTING

        RETURN                     = BAPIRET2

      TABLES

        MATERIALDESCRIPTION        = INT_MAKT.

 

          .

IF SY-SUBRC = 0.

      IF BAPIRET2-TYPE EQ 'E'.

        WRITE:/ 'Error Message - UPDATE FAILED'.

      ELSE.

        COMMIT WORK.

           WRITE:/ ' UPDATE SUCCESSFUL'.

       ENDIF.

ENDIF.

ENDLOOP.

ENDFORM.

Actions