Error during BAPI while uploading Material data through MM01

Hi all,
i am facing one problem when uploading Material data thorough BAPI in MM01.i am attaching the code below and the error given.
but in the debugger all the value is being stored.
REPORT  ZFINISHED_MAT.
Data: Begin of legacy_data occurs 0,
     MATNR LIKE MARA-MATNR,
     MBRSH LIKE MARA-MBRSH,            "Industry Sector
     MTART LIKE MARA-MTART,            "Matl Type
     WERKS LIKE MARD-WERKS,            "Plant
     LGORT LIKE MARD-LGORT,            "Storage location
     VKORG LIKE MVKE-VKORG,
     VTWEG LIKE MVKE-VTWEG,
     MAKTX LIKE MAKT-MAKTX,             "Matl Desc.
     MEINS LIKE MARA-MEINS,             "Base UOM
     MATKL LIKE MARA-MATKL,             "Matl.Grp
*     BISMT LIKE MARA-BISMT,
     SPART LIKE MARA-SPART,             "Division
*     BRGEW LIKE MARA-BRGEW,             "Gross weight
     GROES LIKE MARA-GROES,
     FERTH LIKE MARA-FERTH,
     ZEINR LIKE MARA-ZEINR,
     TAXKM1 LIKE MLAN-TAXM1,
     TAXKM2 LIKE MLAN-TAXM2,
     TAXKM3 LIKE MLAN-TAXM3,
     TAXKM4 LIKE MLAN-TAXM4,
     KTGRM LIKE MVKE-KTGRM,
*     GEWEI LIKE MARA-GEWEI,             "Weight unit
*     NTGEW LIKE MARA-NTGEW,             "Net weight
*     KLART LIKE RMCLF-KLART,
     MTVFP LIKE MARC-MTVFP,             "Availibility Check
*     XGCHP LIKE MARA-XGCHP,
     XCHPF LIKE MARA-XCHPF,             "Batch Management
     TRAGR LIKE MARA-TRAGR,
     LADGR TYPE MARC-LADGR,
     VPRSV LIKE MBEW-VPRSV,            "Price Control
     VERPR LIKE MBEW-VERPR,
*     SPRAS LIKE MAKT-SPRAS,
  END OF LEGACY_DATA.
DATA: BEGIN OF IT_MAKT OCCURS 0.
INCLUDE STRUCTURE BAPI_MAKT.
DATA: END OF IT_MAKT.
*--- BAPI structures
DATA: BAPI_HEAD LIKE BAPIMATHEAD, " Header Segment with Control Information
BAPI_MAKT LIKE BAPI_MAKT, " Material Description
BAPI_MARA1 LIKE BAPI_MARA, " Client Data
BAPI_MARAX LIKE BAPI_MARAX, " Checkbox Structure for BAPI_MARA
BAPI_MARD1 LIKE BAPI_MARD,
BAPI_MARDX1 LIKE BAPI_MARDX, " Checkbox Structure for BAPI_MARD
BAPI_MARC1 LIKE BAPI_MARC, " Plant View
BAPI_MARCX LIKE BAPI_MARCX, " Checkbox Structure for BAPI_MARC
BAPI_MVKE1 LIKE BAPI_MVKE,
BAPI_MVKEX1 LIKE BAPI_MVKEX, " Checkbox Structure for BAPI_MVKE
BAPI_MLAN1 LIKE BAPI_MLAN,
BAPI_MLANX1 LIKE bapi_mlan1, " Checkbox Structure for BAPI_MLAN
BAPI_MBEW1 LIKE BAPI_MBEW, " Accounting View
BAPI_MBEWX LIKE BAPI_MBEWX, " Checkbox Structure for BAPI_MBEW
BAPI_RETURN LIKE BAPIRET2. " Return Parameter
*              $PARAMETERS DECLARATION$
SELECTION-SCREEN BEGIN OF BLOCK B11
                          WITH FRAME TITLE TEXT-001.
PARAMETERS: P_FILE LIKE RLGRAP-FILENAME. " DEFAULT 'C:\TEST1.XLS'.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN ULINE.
SELECTION-SCREEN END OF BLOCK B11 .
*              $DATA DECLARATION$
*DATA : BDC_DATA LIKE STANDARD TABLE OF BDCDATA WITH HEADER LINE.
DATA : IT_EXCEL TYPE STANDARD TABLE OF  ALSMEX_TABLINE INITIAL SIZE 0 WITH HEADER LINE,
        IT_EXCEL_DUMMY TYPE ALSMEX_TABLINE.
DATA : MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
DATA : L_MSTRING(480).
DATA :L_SUBRC LIKE SY-SUBRC.
DATA: V_FILE TYPE STRING.
*              $AT-SELECTON SCREEN DECLARATION$
AT SELECTION-SCREEN ON P_FILE.
  IF P_FILE IS INITIAL.
    MESSAGE E398(00) WITH 'FILE NAME NEEDS TO BE SPECIFIED'.
  ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
  CALL FUNCTION 'F4_FILENAME'
   EXPORTING
     PROGRAM_NAME        = SYST-CPROG
*   DYNPRO_NUMBER       = SYST-DYNNR
     FIELD_NAME          = 'P_FILE'
   IMPORTING
     FILE_NAME           = P_FILE
start-of-selection.
perform data_fetch_to_xls.
perform insertion.
*&      Form  data_fetch_to_xls
*       text
*  -->  p1        text
*  <--  p2        text
FORM data_fetch_to_xls .
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
      FILENAME                = P_FILE
      I_BEGIN_COL             = 1
      I_BEGIN_ROW             = 2
      I_END_COL               = 25
      I_END_ROW               = 2
    TABLES
      INTERN                  = IT_EXCEL
    EXCEPTIONS
      INCONSISTENT_PARAMETERS = 1
      UPLOAD_OLE              = 2
      OTHERS                  = 3.
  IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    WRITE: /'ERROR UPLOADING XLS FILE FROM PRESENTATION SERVER !' ,
           /'RETURN CODE : ', SY-SUBRC.
  ELSE.
*************NOW FILL DATA FROM EXCEL INTO FINAL LEGACY DATA ITAB----LEGACY_DATA***************
    IF NOT IT_EXCEL[] IS INITIAL.
      CLEAR LEGACY_DATA.
      REFRESH LEGACY_DATA[].
      LOOP AT IT_EXCEL.
        IT_EXCEL_DUMMY = IT_EXCEL.
        AT NEW COL.
          CASE IT_EXCEL_DUMMY-COL.
            WHEN 1.
              LEGACY_DATA-MATNR = IT_EXCEL_DUMMY-VALUE(18).
            WHEN 2.
              LEGACY_DATA-MBRSH = IT_EXCEL_DUMMY-VALUE(1).
            WHEN 3.
              LEGACY_DATA-MTART = IT_EXCEL_DUMMY-VALUE(4).
            WHEN 4.
              LEGACY_DATA-WERKS = IT_EXCEL_DUMMY-VALUE(4).
            WHEN 5.
              LEGACY_DATA-LGORT = IT_EXCEL_DUMMY-VALUE(4).
            WHEN 6.
              LEGACY_DATA-VKORG = IT_EXCEL_DUMMY-VALUE(4).
             WHEN 7.
              LEGACY_DATA-VTWEG = IT_EXCEL_DUMMY-VALUE(2).
            WHEN 8.
              LEGACY_DATA-MAKTX = IT_EXCEL_DUMMY-VALUE(40).
            WHEN 9.
              LEGACY_DATA-MEINS = IT_EXCEL_DUMMY-VALUE(3).
            WHEN 10.
              LEGACY_DATA-MATKL = IT_EXCEL_DUMMY-VALUE(9).
            WHEN 11.
              LEGACY_DATA-SPART = IT_EXCEL_DUMMY-VALUE(2).
            WHEN 12.
              LEGACY_DATA-GROES = IT_EXCEL_DUMMY-VALUE(32).
            WHEN 13.
              LEGACY_DATA-FERTH = IT_EXCEL_DUMMY-VALUE(18).
            WHEN 14.
              LEGACY_DATA-ZEINR = IT_EXCEL_DUMMY-VALUE(22).
             WHEN 15.
              LEGACY_DATA-TAXKM1 = IT_EXCEL_DUMMY-VALUE(1).
             WHEN 16.
              LEGACY_DATA-TAXKM2 = IT_EXCEL_DUMMY-VALUE(1).
             WHEN 17.
              LEGACY_DATA-TAXKM3 = IT_EXCEL_DUMMY-VALUE(1).
             WHEN 18.
              LEGACY_DATA-TAXKM4 = IT_EXCEL_DUMMY-VALUE(1).
             WHEN 19.
              LEGACY_DATA-KTGRM = IT_EXCEL_DUMMY-VALUE(2).
            WHEN 20.
              LEGACY_DATA-MTVFP = IT_EXCEL_DUMMY-VALUE(2).
             WHEN 21.
              LEGACY_DATA-XCHPF = IT_EXCEL_DUMMY-VALUE(1).
            WHEN 22.
              LEGACY_DATA-TRAGR = IT_EXCEL_DUMMY-VALUE(4).
            WHEN 23.
              LEGACY_DATA-LADGR = IT_EXCEL_DUMMY-VALUE(4).
            WHEN 24.
              LEGACY_DATA-VPRSV = IT_EXCEL_DUMMY-VALUE(1).
            WHEN 25.
              LEGACY_DATA-VERPR = IT_EXCEL_DUMMY-VALUE(14).
              APPEND LEGACY_DATA.
              CLEAR LEGACY_DATA.
          ENDCASE.
        ENDAT.
        AT END OF ROW.
        ENDAT.
      ENDLOOP.
    ENDIF.
  ENDIF.
ENDFORM.                    " data_fetch_to_xls
*&      Form  insertion
*       text
*  -->  p1        text
*  <--  p2        text
FORM insertion .
LOOP AT legacy_data.
* Header
BAPI_HEAD-MATERIAL = legacy_data-MATNR.
BAPI_HEAD-IND_SECTOR = legacy_data-MBRSH.
BAPI_HEAD-MATL_TYPE = legacy_data-MTART.
BAPI_HEAD-BASIC_VIEW = 'X'.
BAPI_HEAD-SALES_VIEW = 'X'.
BAPI_HEAD-STORAGE_VIEW = 'X'.
*BAPI_HEAD-PURCHASE_VIEW = 'X'.
BAPI_HEAD-ACCOUNT_VIEW = 'X'.
* Material Description
REFRESH IT_MAKT.
*IT_MAKT-LANGU = legacy_data-SPRAS.
IT_MAKT-MATL_DESC = legacy_data-MAKTX.
APPEND IT_MAKT.
BAPI_MARD1-PLANT = legacy_data-WERKS.
BAPI_MARD1-STGE_LOC = legacy_data-LGORT.
BAPI_MARDX1-PLANT = legacy_data-WERKS.
BAPI_MARDX1-STGE_LOC = legacy_data-LGORT.
** Client Data - Basic
BAPI_MARA1-MATL_GROUP = legacy_data-MATKL.
*bapi_mara1-OLD_MAT_NO = legacy_data-bismt.
BAPI_MARA1-BASE_UOM = legacy_data-MEINS.
BAPI_MARA1-PROD_MEMO = LEGACY_DATA-FERTH.
BAPI_MARA1-SIZE_DIM = LEGACY_DATA-GROES.
BAPI_MARA1-DOCUMENT = LEGACY_DATA-ZEINR.
BAPI_MARA1-BATCH_MGMT = LEGACY_DATA-XCHPF.
*BAPI_MARA1-UNIT_OF_WT = legacy_data-GEWEI.
BAPI_MARA1-TRANS_GRP = legacy_data-TRAGR.
BAPI_MARA1-DIVISION = legacy_data-SPART.
BAPI_MARAX-MATL_GROUP = 'X'.
*BAPI_MARAX-OLD_MAT_NO = 'X'.
BAPI_MARAX-BASE_UOM = 'X'.
BAPI_MARAX-PROD_MEMO = 'X'.
BAPI_MARAX-SIZE_DIM = 'X'.
BAPI_MARAX-DOCUMENT = 'X'.
BAPI_MARAX-BATCH_MGMT = 'X'.
*BAPI_MARAX-UNIT_OF_WT = 'X'.
BAPI_MARAX-TRANS_GRP = 'X'.
BAPI_MARAX-DIVISION = 'X'.
*SALES
BAPI_MVKE1-SALES_ORG = legacy_data-VKORG.
BAPI_MVKE1-DISTR_CHAN = legacy_data-VTWEG.
*BAPI_MVKE1-DELYG_PLNT = legacy_data-DWERK.
BAPI_MVKE1-ACCT_ASSGT = legacy_data-KTGRM.
BAPI_MVKEX1-SALES_ORG = legacy_data-VKORG.
BAPI_MVKEX1-DISTR_CHAN = legacy_data-VTWEG.
*BAPI_MVKEX1-DELYG_PLNT = 'X'.
BAPI_MVKEX1-ACCT_ASSGT = 'X'.
** Plant - Purchasing
BAPI_MARC1-PLANT = legacy_data-WERKS.
BAPI_MARC1-LOADINGGRP = legacy_data-LADGR.
BAPI_MARC1-AVAILCHECK = legacy_data-MTVFP.
*BAPI_MARC1-MRP_GROUP =  legacy_data-disgr.
BAPI_MARCX-PLANT = legacy_data-WERKS.
BAPI_MARCX-LOADINGGRP = 'X'.
BAPI_MARCX-AVAILCHECK = 'X'.
*BAPI_MARCX-MRP_GROUP =  'X'.
* Accounting
BAPI_MBEW1-VAL_AREA = legacy_data-WERKS.
BAPI_MBEW1-PRICE_CTRL = legacy_data-VPRSV.
BAPI_MBEW1-STD_PRICE =  legacy_data-VERPR.
*BAPI_MBEW1-VAL_CLASS =  legacy_data-BKLAS.
*BAPI_MBEW1-STD_PRICE = legacy_data-STPRS.
*BAPI_MBEW1-PRICE_UNIT = legacy_data-PEINH.
BAPI_MBEWX-VAL_AREA = legacy_data-WERKS.
BAPI_MBEWX-PRICE_CTRL = 'X'.
BAPI_MBEWX-STD_PRICE =  'X'.
*BAPI_MBEWX-VAL_CLASS =  'X'.
* TAX JURISDICTION CODE
BAPI_MLAN1-TAXCLASS_1 = LEGACY_DATA-TAXKM1.
BAPI_MLAN1-TAXCLASS_2 = LEGACY_DATA-TAXKM2.
BAPI_MLAN1-TAXCLASS_3 = LEGACY_DATA-TAXKM3.
BAPI_MLAN1-TAXCLASS_4 = LEGACY_DATA-TAXKM4.
BAPI_MLAN1-TAXCLASS_1 = 'X'.
BAPI_MLAN1-TAXCLASS_2 = 'X'.
BAPI_MLAN1-TAXCLASS_3 = 'X'.
BAPI_MLAN1-TAXCLASS_4 = 'X'.
*--- BAPI to create material
call function 'BAPI_MATERIAL_SAVEDATA'
exporting
HEADDATA = BAPI_HEAD
CLIENTDATA = BAPI_MARA1
CLIENTDATAX = BAPI_MARAX
*PLANTDATA = BAPI_MARC1
*PLANTDATAX = BAPI_MARCX
* FORECASTPARAMETERS =
* FORECASTPARAMETERSX =
* PLANNINGDATA =
* PLANNINGDATAX =
* STORAGELOCATIONDATA =
* STORAGELOCATIONDATAX =
VALUATIONDATA = BAPI_MBEW1
VALUATIONDATAX = BAPI_MBEWX
* WAREHOUSENUMBERDATA =
* WAREHOUSENUMBERDATAX =
* SALESDATA = BAPI_MVKE1
* SALESDATAX = BAPI_MVKEX
* STORAGETYPEDATA =
* STORAGETYPEDATAX =
IMPORTING
RETURN = BAPI_RETURN
TABLES
MATERIALDESCRIPTION = IT_MAKT
* UNITSOFMEASURE =
* UNITSOFMEASUREX =
* INTERNATIONALARTNOS =
* MATERIALLONGTEXT =
* TAXCLASSIFICATIONS =
* RETURNMESSAGES =
* PRTDATA =
* PRTDATAX =
* EXTENSIONIN =
* EXTENSIONINX =
IF BAPI_RETURN-TYPE = 'E'.
WRITE:/ 'Error:' ,BAPI_RETURN-MESSAGE ,'for material:' ,legacy_data-maTNR.
ELSEIF BAPI_RETURN-TYPE = 'S'.
WRITE: 'Successfully created material' ,legacy_data-maTNR.
ENDIF.
ENDLOOP.
ENDFORM.                    " insertion
The error: The field MARC-MTVFP/BAPI_MARC-AVAILCHECK is defined as a required field; it does not contain an entr
suggestion will be vry helpful,
Kind Regards,
Edited by: Prasenjit Sengupta on Nov 16, 2009 9:11 AM
Advertisement
Reply

Hi Prasenjit,
Did you get any solution for this as I am getting same error from BAPI to update MRP controller in MARC table.
Regards,
Suruchi