Create material using bapi_material_savedata

Hi.
I'm having prob with creation of material using bapi_material_savedata. When creating new material we use internal numbering so I use first bapi_material_getintnumber'. the number from that bapi is what i used in bapi_material_savedata. However, I getting an error that says 'matnr <from bapi>does not exists', why is this so? do i need to put the commit after the bapi_material_getintnumber and before calling the bapi_material_savedata?
Please help.
thnx.

hi
good
go through this example and use accordingly
REPORT ZBAPIMM01 LINE-SIZE 255 NO STANDARD PAGE HEADING
                 LINE-COUNT 065(001).
TABLES: T001L, "Storage Locations
        MARA,  "General Material Data
        MAKT,  "Material Descriptions
        MBEW,  "Material Valuation
        MARC.  "Plant Data for Material
DATA: BAPI_HEAD   LIKE BAPIMATHEAD,
      BAPI_MAKT   LIKE BAPI_MAKT,    "Material Description
      BAPI_MARA1  LIKE BAPI_MARA,    "Client Data
      BAPI_MARAX  LIKE BAPI_MARAX,
      BAPI_MARC1  LIKE BAPI_MARC,    "Plant View
      BAPI_MARCX  LIKE BAPI_MARCX,
      BAPI_MBEW1  LIKE BAPI_MBEW,    "Accounting View
      BAPI_MBEWX  LIKE BAPI_MBEWX,
      BAPI_RETURN LIKE BAPIRET2.
DATA: BEGIN OF INT_MAKT OCCURS 100.
        INCLUDE STRUCTURE BAPI_MAKT.
DATA: END OF INT_MAKT.
DATA: BEGIN OF INT_MAT OCCURS 100,
         WERKS(4),     "Plant
         MTART(4),     "Material type
         MATNR(18),    "Material number
         MATKL(9) ,    "Material group
         MBRSH(1),     "Industry sector
         MEINS(3),     "Base unit of measure
         GEWEI(3),     "Weight Unit
         SPART(2),     "Division
         EKGRP(3),     "Purchasing group
         VPRSV(1),     "Price control indicator
         STPRS(12),    "Standard price
         PEINH(3),     "Price unit
         SPRAS(2),     "Language key
         MAKTX(40),     "Material description
       END OF INT_MAT.
SELECT-OPTIONS:
            PLANT    FOR  MARC-WERKS OBLIGATORY MEMORY ID PLT,
            MATERIAL FOR  MARA-MATNR MEMORY ID MAT,
            MATLTYPE FOR  MARA-MTART MEMORY ID MTY,
            DIVISION FOR  MARA-SPART MEMORY ID DIV.
PARAMETERS:  F_FILE LIKE RLGRAP-FILENAME
             DEFAULT 'C:\DATA\ZMATERIAL.XLS' MEMORY ID F_FILE,
             GETDATA AS CHECKBOX, "Tick to download materials data to local harddisk
             UPDDATA AS CHECKBOX. "Tick to update date to Materials Master
IF GETDATA = 'X'.
   PERFORM DOWNLOAD_DATA.
   PERFORM DOWNLOAD_FILE.
ENDIF.
IF UPDDATA = 'X'.
   PERFORM UPLOAD_FILE.
   PERFORM UPDATE_MM.
ENDIF.
FORM DOWNLOAD_DATA.
SELECT * FROM MARC  WHERE LVORM EQ ' '
                      AND WERKS IN PLANT
                      AND MATNR IN MATERIAL.
    CLEAR MARA.
    SELECT SINGLE * FROM MARA WHERE MATNR =  MARC-MATNR.
    CHECK MATLTYPE.
    CHECK DIVISION.
    CLEAR MBEW.
    SELECT SINGLE * FROM MBEW WHERE MATNR =  MARC-MATNR
                                AND BWKEY =  MARC-WERKS.
    CLEAR MAKT.
    SELECT SINGLE * FROM MAKT WHERE SPRAS =  'EN'
                                AND MATNR =  MARC-MATNR.
    WRITE:/ MARC-WERKS,    "Plant
            MARA-MTART,    "Material type
            MARA-MATNR,    "Material number
            MARA-MATKL,    "Material group
            MARA-MBRSH,    "Industry sector
            MARA-MEINS,    "Base unit of measure
            MARA-GEWEI,    "Weight Unit
            MARA-SPART,    "Division
            MARC-EKGRP,    "Purchasing group
            MBEW-VPRSV,    "Price control indicator
            MBEW-STPRS,    "Standard price
            MBEW-PEINH,    "Price unit
            MAKT-SPRAS,    "Language key
            MAKT-MAKTX.    "Material description
            INT_MAT-WERKS = MARC-WERKS.    "Plant
            INT_MAT-MTART = MARA-MTART.    "Material type
            INT_MAT-MATNR = MARA-MATNR.    "Material number
            INT_MAT-MATKL = MARA-MATKL.    "Material group
            INT_MAT-MBRSH = MARA-MBRSH.    "Industry sector
            INT_MAT-MEINS = MARA-MEINS.    "Base unit of measure
            INT_MAT-GEWEI = MARA-GEWEI.    "Weight Unit
            INT_MAT-SPART = MARA-SPART.    "Division
            INT_MAT-EKGRP = MARC-EKGRP.    "Purchasing group
            INT_MAT-VPRSV = MBEW-VPRSV.    "Price control indicator
            INT_MAT-STPRS = MBEW-STPRS.    "Standard price
            INT_MAT-PEINH = MBEW-PEINH.    "Price unit
            INT_MAT-SPRAS = MAKT-SPRAS.    "Language key
            INT_MAT-MAKTX = MAKT-MAKTX.    "Material description
            APPEND INT_MAT.
            CLEAR  INT_MAT.
ENDSELECT.
ENDFORM.
FORM DOWNLOAD_FILE.
call function 'WS_DOWNLOAD'
  EXPORTING
    FILENAME                      = F_FILE
    FILETYPE                      = 'DAT'
  FILETYPE                      = 'WK1'
  tables
    data_tab                      = INT_MAT
  EXCEPTIONS
    FILE_OPEN_ERROR               = 1
    FILE_WRITE_ERROR              = 2
    INVALID_FILESIZE              = 3
    INVALID_TYPE                  = 4
    NO_BATCH                      = 5
    UNKNOWN_ERROR                 = 6
    INVALID_TABLE_WIDTH           = 7
    GUI_REFUSE_FILETRANSFER       = 8
    CUSTOMER_ERROR                = 9
    OTHERS                        = 10.
IF SY-SUBRC = 0.
   FORMAT COLOR COL_GROUP.
   WRITE:/ 'Data Download Successfully to your local harddisk'.
   SKIP.
ENDIF.
ENDFORM.
FORM UPLOAD_FILE.
call function 'WS_UPLOAD'
  EXPORTING
    FILENAME                      = F_FILE
    FILETYPE                      = 'DAT'
  FILETYPE                      = 'WK1'
  tables
    data_tab                      = INT_MAT
  EXCEPTIONS
    FILE_OPEN_ERROR               = 1
    FILE_WRITE_ERROR              = 2
    INVALID_FILESIZE              = 3
    INVALID_TYPE                  = 4
    NO_BATCH                      = 5
    UNKNOWN_ERROR                 = 6
    INVALID_TABLE_WIDTH           = 7
    GUI_REFUSE_FILETRANSFER       = 8
    CUSTOMER_ERROR                = 9
    OTHERS                        = 10.
IF SY-SUBRC = 0.
   FORMAT COLOR COL_GROUP.
   WRITE:/ 'Data Upload Successfully from your local harddisk'.
   SKIP.
ENDIF.
ENDFORM.
FORM UPDATE_MM.
LOOP AT INT_MAT.
Header
    BAPI_HEAD-MATERIAL        = INT_MAT-MATNR.
    BAPI_HEAD-IND_SECTOR      = INT_MAT-MBRSH.
    BAPI_HEAD-MATL_TYPE       = INT_MAT-MTART.
    BAPI_HEAD-BASIC_VIEW      = 'X'.
    BAPI_HEAD-PURCHASE_VIEW   = 'X'.
    BAPI_HEAD-ACCOUNT_VIEW    = 'X'.
Material Description
    REFRESH INT_MAKT.
    INT_MAKT-LANGU           = INT_MAT-SPRAS.
    INT_MAKT-MATL_DESC       = INT_MAT-MAKTX.
    APPEND INT_MAKT.
Client Data - Basic
    BAPI_MARA1-MATL_GROUP     = INT_MAT-MATKL.
    BAPI_MARA1-BASE_UOM       = INT_MAT-MEINS.
    BAPI_MARA1-UNIT_OF_WT     = INT_MAT-GEWEI.
    BAPI_MARA1-DIVISION       = INT_MAT-SPART.
    BAPI_MARAX-MATL_GROUP = 'X'.
    BAPI_MARAX-BASE_UOM   = 'X'.
    BAPI_MARAX-UNIT_OF_WT = 'X'.
    BAPI_MARAX-DIVISION   = 'X'.
Plant - Purchasing
    BAPI_MARC1-PLANT      = INT_MAT-WERKS.
    BAPI_MARC1-PUR_GROUP  = INT_MAT-EKGRP.
    BAPI_MARCX-PLANT      = INT_MAT-WERKS.
    BAPI_MARCX-PUR_GROUP  = 'X'.
Accounting
    BAPI_MBEW1-VAL_AREA   = INT_MAT-WERKS.
    BAPI_MBEW1-PRICE_CTRL = INT_MAT-VPRSV.
    BAPI_MBEW1-STD_PRICE  = INT_MAT-STPRS.
    BAPI_MBEW1-PRICE_UNIT = INT_MAT-PEINH.
    BAPI_MBEWX-VAL_AREA   = INT_MAT-WERKS.
    BAPI_MBEWX-PRICE_CTRL = 'X'.
    BAPI_MBEWX-STD_PRICE  = 'X'.
    BAPI_MBEWX-PRICE_UNIT = 'X'.
    WRITE:/ BAPI_HEAD, BAPI_MARC1.
    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        = INT_MAKT
      UNITSOFMEASURE             =
      UNITSOFMEASUREX            =
      INTERNATIONALARTNOS        =
      MATERIALLONGTEXT           =
      TAXCLASSIFICATIONS         =
      RETURNMESSAGES             =
      PRTDATA                    =
      PRTDATAX                   =
      EXTENSIONIN                =
      EXTENSIONINX               =
IF BAPI_RETURN-TYPE = 'E'.
   WRITE:/ 'Error Message ', BAPI_RETURN.
ENDIF.
ENDLOOP.
ENDFORM.
*---End of Program
thanks
mrutyun^

Similar Messages

  • How to create material using BAPI_material_savedata.

    hi,
    i try to create the material by using a bapi BAPI_MATERIAL_SAVEDATA , every thing i s going good material is created but only the MFRPN (manufacrurer part number ) is not updated.
    thanks in advance.

    Hi Ritesh,
    Plz check out this link;
    [Creation of BAPI using BAPI_material_savedata|https://wiki.sdn.sap.com/wiki/display/Snippets/Tutorial%2CMM01UploadusingBAPI]
    But plz check the mandatory fields to be passed to the BAPI.
    with regards,
    Mamta
    Edited by: Mamta Kumari on Aug 20, 2009 3:14 PM

  • Error while creating a material using Bapi_material_savedata

    Hi,
    there is an error encountered while creating a material using BAPI_MATERIAL_SAVEDATA..
    The Error description is " Material description is not transfered " even after supplying the Material description and other mandatory field information like industrial sector, material type ,basic view indicator,Base UOM,Base UOM ISO code.
    Please let me know the solution, if you know.

    Hi,
    Please search the SCN for the answers
    https://www.sdn.sap.com/irj/scn/advancedsearch?query=errorinBAPI_MATERIAL_SAVEDATA+&cat=sdn_all

  • Create material using bapi ' bapi_material_savedata'

    Hi Experts,
    i was tring to create material using bapi ' bapi_material_savedata' but the material is not updating in the table.
    please find the code and suggest me if any modification
    data: la_headdata type BAPIMATHEAD,
    la_clientdata type BAPI_MARA,
    la_CLIENTDATAX type BAPI_MARAX,
    la_return type BAPIRET2.
    data: i_materialdescription type table of BAPI_MAKT,
    wa_materialdescription like line of i_materialdescription.
    *la_headdata-MATERIAL = int_matnum-MATERIAL.
    *LOOP AT int_matnum.
    la_headdata-MATERIAL = int_matnum-MATERIAL.
    write : int_matnum-material.
    *ENDLOOP.
    la_headdata-MATERIAL = '100000518'."int_matnum-MATERIAL.
    la_headdata-IND_SECTOR = p_indsr.
    la_headdata-MATL_TYPE = p_matype.
    la_clientdata-BASE_UOM = 'FT3'.
    la_clientdata-pur_valkey = ' '.
    la_CLIENTDATAX-BASE_UOM = 'X'.
    la_clientdata-MATL_GROUP = '01'.
    la_CLIENTDATAX-MATL_GROUP = 'X'.
    wa_materialdescription = 'TEST'.
    append wa_materialdescription to i_materialdescription.
    clear: wa_materialdescription.
    CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
    EXPORTING
    headdata = la_headdata
    CLIENTDATA = la_clientdata
    CLIENTDATAX = la_CLIENTDATAX
    PLANTDATA =
    PLANTDATAX =
    FORECASTPARAMETERS =
    FORECASTPARAMETERSX =
    PLANNINGDATA =
    PLANNINGDATAX =
    STORAGELOCATIONDATA =
    STORAGELOCATIONDATAX =
    VALUATIONDATA =
    VALUATIONDATAX =
    WAREHOUSENUMBERDATA =
    WAREHOUSENUMBERDATAX =
    SALESDATA =
    SALESDATAX =
    STORAGETYPEDATA =
    STORAGETYPEDATAX =
    FLAG_ONLINE = ' '
    FLAG_CAD_CALL = ' '
    IMPORTING
    RETURN = la_return
    TABLES
    MATERIALDESCRIPTION = i_materialdescription
    UNITSOFMEASURE =
    UNITSOFMEASUREX =
    INTERNATIONALARTNOS =
    MATERIALLONGTEXT =
    TAXCLASSIFICATIONS =
    RETURNMESSAGES =
    PRTDATA =
    PRTDATAX =
    EXTENSIONIN =
    EXTENSIONINX =
    Please Help me
    Regards,
    Naresh

    Hi all,
    Now it is asking me for the other fields,
    E ,
    The field MARA-XCHPF/BAPI_MARA-BATCH_MGMT is defined as a required field; it does not contain an entry
    i have passed this val as
    la_clientdata-batch_mgmt = 'X'.
    even though i am getting the same error.
    can you help me to solve the issue.
    Tthanks
    Naresh
    Edited by: naresh.k.dasari on Jan 4, 2011 10:36 AM

  • I can create material using inbound Idoc of type MATMAS01, but not MATMAS05

    I can create material using inbound Idoc of type MATMAS01 in WE19, but MATMAS05 failed. In fact I used same data ( different material number), and same inbound function, but got different result.
    What is different between MATMAS01 and MATMAS05? Is there some configuation need for MATMAS05?
    My system is ECC5.0. Thanks.

    Hi, nagaraj
    this is inbound IDoc, not outbound IDoc, so we can't assign Basic type in WE20, only can assign Message type.
    In WE82, there are 5 records about Messagetype MATMAS:
         Message type   Basic type     Release
          MATMAS         MATMAS01        30A
          MATMAS         MATMAS02        30D
          MATMAS         MATMAS03        40A
          MATMAS         MATMAS04        46C
          MATMAS         MATMAS05        470
       I think it should be ok.
    In WE57, there 2 records are exist:
       FM_name                 BasicType       MessageType
      IDOC_INPUT_MATMAS01       MATMAS01         MATMAS
      IDOC_INPUT_MATMAS01       MATMAS05         MATMAS
    so I think all configurations should be ok.
    Message was edited by:
            liu bin

  • Create Material With BAPI_MATERIAL_SAVEDATA

    Hi,
    I New To SAP I'm Trying To Create Material With BAPI_MATERIAL_SAVEDATA . When I Execute The Code I am Getting Message That ' Bytes Transfered' But When I Checking The MARA Table I Cannot Find The Enteries..
    *************************************************************CODE*********************************************************************************
    TABLES: bapimathead,
                  bapi_mara,
                  bapi_marax,
                  bapiret2.
    TYPES: BEGIN OF lsmw_material_master,
                 matnr TYPE mara-matnr,
                 mtart  TYPE mara-mtart,
                 mbrsh TYPE mara-mbrsh,
                 maktx TYPE makt-maktx,
                 meins TYPE mara-meins,
                 END   OF  lsmw_material_master.
    DATA: it_master        TYPE TABLE OF lsmw_material_master,
                wa_master     TYPE  lsmw_material_master,
                it_materialdesc TYPE TABLE OF bapi_makt WITH HEADER LINE,
                it_return            LIKE bapiret2.
    SELECTION-SCREEN: BEGIN OF BLOCK a1 WITH FRAME TITLE text-001.
               PARAMETERS: p_file TYPE rlgrap-filename OBLIGATORY.
    SELECTION-SCREEN: END OF BLOCK a1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
       DATA: it_tab   TYPE filetable,
                 iv_subrc LIKE sy-subrc.
    CALL METHOD cl_gui_frontend_services=>file_open_dialog
         EXPORTING
                window_title            = 'Select Source File'
        CHANGING
                file_table              = it_tab
                rc                      = iv_subrc
       IF sy-subrc <> 0.
    *             MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
       ENDIF.
       LOOP AT it_tab INTO p_file.
       ENDLOOP.
    CALL FUNCTION 'UPLOAD'
        EXPORTING
               filename                    = p_file
               filetype                      = 'DAT'
       TABLES
               data_tab                      = it_master
       IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
       ENDIF.
    LOOP AT it_master INTO wa_master.
         bapimathead-material        = wa_master-matnr.
         bapimathead-ind_sector    = wa_master-mtart.
         bapimathead-matl_type     = wa_master-mbrsh.
         bapimathead-basic_view    = 'X'.
         bapi_mara-base_uom        = wa_master-meins.
         bapi_marax-base_uom       = 'X'.
         it_materialdesc-matl_desc = wa_master-maktx.
         APPEND it_materialdesc.
    CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
       EXPORTING
              headdata                    = bapimathead
              clientdata                    = bapi_mara
              CLIENTDATAX             = bapi_marax
      IMPORTING
              return                          = it_return
      TABLES
              materialdescription       = it_materialdesc
    ENDLOOP.
      IF  sy-subrc = 0.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    *     EXPORTING
    *       WAIT          =
    *     IMPORTING
    *       RETURN        =
    * ELSE.
       WRITE:/ 'Error'.
    *   CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'
    *   IMPORTING
    *     RETURN        =
      ENDIF.
    *************************************************************FILE >>>>>check.text.********************************************************************************
    Cooinfl_Fan
    E
    FERT
    FANS
    PC
    Bathing_Fan
    E
    FERT
    FANS
    PC

    Please pass following values:
      it_materialdesc-matl_desc = wa_master-maktx.
      it_materialdesc-langu  = 'E'.
      it_materialdesc-langu_iso = 'EN'.
         APPEND it_materialdesc.
    Regards

  • Create material using reference material

    Hi All,
    I need to create a material using a reference material. I am using the BAPI_MATERIAL_SAVEREPLICA and passing the reference material in the PL_REF_MAT field. But this is not working fine. I have searcged the forums as well but couldn't find any solution.
    Another solution that I am thinking to implement is to use BAPI_MATERIAL_GETALL and get the details of the reference material and then pass those details to the BAPI_MATERIAL_SAVEREPLICA. But as the structures for the two BAPI's are different I need to mapo each field one by one which is quite cumbersome as each view of the material has almost 100 or more fields.
    Please suggest.
    Thanks,
    Manish

    Hi Goutam,
    You can use the BAPI BAPI_MATERIAL_SAVEDATA, which will create/update the material. You can pass the reference material in the filed BAPI_MARA-PL_REF_MAT. And you can pass reference material for all view like this.

  • Error while creating material using MMS1

    Hi All ,
             I am trying to create material (Material type - DIEN) using MMS1.... but its giving error as "The field Component 1 is defined as a required field; it does not contain an entry" .
            Pls suggest / advice on how to correct this error ....
    Thanks ,
    Mridul .

    hi,
    i believe some finctional consultant having knowledge in MM module can easily help u out on this.
    reg,
    nj

  • Create Material using MATMAS05 IDOC

    Hi Gurus,
    Please tell me what are the mandatory fields and tables for those fields to create a Material using MATMAS05 standard IDOC.

    Hi,
    Fields are  never mandatory while sending the idocs. Its the segment which is mandatory.
    If you see the definition of MATMAS05 idoc in transaction WE30 you will find E1MARAM  and E1MAKTM,  as a mandatory segment. It means that you can't send an Idoc without this segment. If you go in segment details than even if you populate a single field in the segment E1MARAM and E1MAKTM then you can send the idocs.
    KR Jaideep,

  • Create Material- Using authority by material type

    Hi Experts
    I want to  set authority for user to create material by using  material type. User will create only those  material in which they are assigned in specific material type.
    Please help me to solve this problem.

    Hi,
    You can proceed in the following way regarding this issue
    1] In OMS2, maintain the Authorization Group for a particular Material Type
    2] Maintain this Authorization Group in the activities of MM01 T-code with the help of Basis
    3] This will ensure that authorized user only can create material master for that material type
    Regards,
    Amol

  • How to create material using BAPI  Methods?

    hi,
    how to create material master dat using BAPI?
    could u guide me
    i will be waiting for reply.
    REGARDS
    ESWAR.

    Hi eswar,
    Try this code to create gods mmovement...
    DATA: GOODSMVT_HEADER LIKE BAPI2017_GM_HEAD_01,
          " Material Document Header Data
          GOODSMVT_CODE LIKE BAPI2017_GM_CODE,
          " Assign code to transaction for BAPI goods movement
          MATERIALDOCUMENT LIKE BAPI2017_GM_HEAD_RET-MAT_DOC,
          " Number of Material Document
          GOODSMVT_ITEM LIKE BAPI2017_GM_ITEM_CREATE OCCURS 0 WITH HEADER
          LINE,
          " Create Material Document Item
          RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE
          " Return table for messages
    *Fill values in header
    GOODSMVT_HEADER-PSTNG_DATE = '20030825'.
    GOODSMVT_HEADER-DOC_DATE = '20030802'.
    *Fill GOODSMVT_CODE
    GOODSMVT_CODE-GM_CODE = '05' .
    *Fill Item Table
    GOODSMVT_ITEM-MATERIAL = '100-100'.
    GOODSMVT_ITEM-PLANT = '1000'.
    GOODSMVT_ITEM-STGE_LOC = '0001'.
    GOODSMVT_ITEM-MOVE_TYPE = '501'.
    GOODSMVT_ITEM-ENTRY_QNT = '50'.
    GOODSMVT_ITEM-ITEM_TEXT = 'Test Sanket'.
    *GOODSMVT_ITEM-COSTCENTER = '1000'.
    APPEND GOODSMVT_ITEM.
    *Create Good's movement
    CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
      EXPORTING
        GOODSMVT_HEADER  = GOODSMVT_HEADER
        GOODSMVT_CODE    = GOODSMVT_CODE
      IMPORTING
        MATERIALDOCUMENT = MATERIALDOCUMENT
      TABLES
        GOODSMVT_ITEM    = GOODSMVT_ITEM
        RETURN           = RETURN.
    *Commit BAPI
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
        WAIT = 'X'.
    *Display Goods movement number
    FORMAT COLOR 6 INVERSE ON.
    READ TABLE RETURN WITH KEY TYPE = 'E'.
    IF SY-SUBRC = 0.
      WRITE: /,'ERROR! Goods movement not created'.
    ELSE.
      WRITE: /,'Goods movent number',MATERIALDOCUMENT COLOR 5,
               'posted for material',GOODSMVT_ITEM-MATERIAL.
    ENDIF.
    FORMAT COLOR OFF INVERSE OFF.
    try this on report program and create a goods movement.
    Sanket.

  • Creating Material Using BAPI

    Hi Friends,
    I want to create a material using BAPI, can anyone give me some sample program or can any one give me links which earlier posted this problem.
    Points for sure for sample program.
    thanks and regards
    Vijaya

    hi
    good
    go through this REPORT z_bapi_salesorder_create.
    Parameters
    Sales document type
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text FOR FIELD p_auart.
    PARAMETERS: p_auart TYPE auart OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    Sales organization
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text1 FOR FIELD p_vkorg.
    PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    Distribution channel
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text2 FOR FIELD p_vtweg.
    PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    Division.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text3 FOR FIELD p_spart.
    PARAMETERS: p_spart TYPE spart OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    SKIP 1.
    Sold-to
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text4 FOR FIELD p_sold.
    PARAMETERS: p_sold  TYPE kunnr OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    Ship-to
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text5 FOR FIELD p_ship.
    PARAMETERS: p_ship  TYPE kunnr OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    SKIP 1.
    Material
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text6 FOR FIELD p_matnr.
    PARAMETERS: p_matnr TYPE matnr   OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    Quantity.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text7 FOR FIELD p_menge.
    PARAMETERS: p_menge TYPE kwmeng  OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    Plant
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text9 FOR FIELD p_plant.
    PARAMETERS: p_plant TYPE werks_d OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    Data declarations.
    DATA: v_vbeln            LIKE vbak-vbeln.
    DATA: header             LIKE bapisdhead1.
    DATA: headerx            LIKE bapisdhead1x.
    DATA: item               LIKE bapisditem  OCCURS 0 WITH HEADER LINE.
    DATA: itemx              LIKE bapisditemx OCCURS 0 WITH HEADER LINE.
    DATA: partner            LIKE bapipartnr  OCCURS 0 WITH HEADER LINE.
    DATA: return             LIKE bapiret2    OCCURS 0 WITH HEADER LINE.
    DATA: lt_schedules_inx   TYPE STANDARD TABLE OF bapischdlx
                             WITH HEADER LINE.
    DATA: lt_schedules_in    TYPE STANDARD TABLE OF bapischdl
                             WITH HEADER LINE.
    Initialization.
    INITIALIZATION.
    v_text   = 'Order type'.
    v_text1  = 'Sales Org'.
    v_text2  = 'Distribution channel'.
    v_text3  = 'Division'.
    v_text4  = 'Sold-to'.
    v_text5  = 'Ship-to'.
    v_text6  = 'Material'.
    v_text7  = 'Quantity'.
    v_text9  = 'Plant'.
    Start-of-selection.
    START-OF-SELECTION.
    Header data
    Sales document type
      header-doc_type = p_auart.
      headerx-doc_type = 'X'.
    Sales organization
      header-sales_org = p_vkorg.
      headerx-sales_org = 'X'.
    Distribution channel
      header-distr_chan  = p_vtweg.
      headerx-distr_chan = 'X'.
    Division
      header-division = p_spart.
      headerx-division = 'X'.
      headerx-updateflag = 'I'.
    Partner data
    Sold to
      partner-partn_role = 'AG'.
      partner-partn_numb = p_sold.
      APPEND partner.
    Ship to
      partner-partn_role = 'WE'.
      partner-partn_numb = p_ship.
      APPEND partner.
    ITEM DATA
      itemx-updateflag = 'I'.
    Line item number.
      item-itm_number = '000010'.
      itemx-itm_number = 'X'.
    Material
      item-material = p_matnr.
      itemx-material = 'X'.
    Plant
      item-plant    = p_plant.
      itemx-plant   = 'X'.
    Quantity
      item-target_qty = p_menge.
      itemx-target_qty = 'X'.
      APPEND item.
      APPEND itemx.
      Fill schedule lines
      lt_schedules_in-itm_number = '000010'.
      lt_schedules_in-sched_line = '0001'.
      lt_schedules_in-req_qty    = p_menge.
      APPEND lt_schedules_in.
      Fill schedule line flags
      lt_schedules_inx-itm_number  = '000010'.
      lt_schedules_inx-sched_line  = '0001'.
      lt_schedules_inx-updateflag  = 'X'.
      lt_schedules_inx-req_qty     = 'X'.
      APPEND lt_schedules_inx.
    Call the BAPI to create the sales order.
      CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'
           EXPORTING
                sales_header_in     = header
                sales_header_inx    = headerx
           IMPORTING
                salesdocument_ex    = v_vbeln
           TABLES
                return              = return
                sales_items_in      = item
                sales_items_inx     = itemx
                sales_schedules_in  = lt_schedules_in
                sales_schedules_inx = lt_schedules_inx
                sales_partners      = partner.
    Check the return table.
      LOOP AT return WHERE type = 'E' OR type = 'A'.
        EXIT.
      ENDLOOP.
      IF sy-subrc = 0.
        WRITE: / 'Error in creating document'.
      ELSE.
    Commit the work.
        COMMIT WORK AND WAIT.
        WRITE: / 'Document ', v_vbeln, ' created'.
      ENDIF.
    thanks
    mrutyun^

  • Create view for Material using BAPI_MATERIAL_SAVEDATA

    Hello. I need create Accounting View(1&2) and Costing View(1&2) using FM BAPI_MATERIAL_SAVEDATA, but i don't now who importing values are required for this...
    please HELP!!!!

    Hi,
    Check this link.
    http://sap-img.com/abap/bapi-to-copy-materials-from-one-plant-to-another.htm
    Thanks,
    Anitha

  • Creating material using MM01

    Hello Experts,
    I have a requirment where in, I need to create 4 materials of type
    MOVE_IN
    MOVE_OUT
    CANCEL_MOVE_IN
    SWITCH_PROVIDER
    Please help in resloving. I need to create them by evening.
    Thanks,
    Suma.

    Hi,
    Use t. Code: MM01,
    Step-1
    Enter Material Code: ( example-MOVE_IN)
    Enter Industry Sector:  ………
    Enter Material Type:  ………….
    Step-2
    Select
    Views you required( like eample:basic data-1,  like basic data-2,purachsing, purchase order text,General plant data, accounting-1, accounting-2  etc)
    Step-3
    Enter Plant,
    Enter Storage location
    {{{Enter Sales organization & Distribution channel(if sales view selected)}}}
    Step-4
    You will have views like (example-1, basic data, enter Base unit of measure, material group and other details as required field,example-2,Accounting data, enter valuation class, price control; S or V & price)
    Step-5
    Save.
    Note: Before creation material you must know which Industry Sector, Material Type ur going to use and material numbering is internal or external.
    For more, check the following link
    http://www.synactive.com/docu_e/doc_multi_mm01.html
    Regards,
    Biju K

  • Create material using LSMW

    Hello LSMW experts,
    I want to upload material master from flat file with some Plant and Sales Organization views in single load. But I am not sure how to map the header data (basic data), sales organization and plant data to the tool. Do I need to have separate files for basic data, sales org, and plant?
    Is there anybody can help me on this? Thanks in advance.
    Zamri

    hi,
    Check this link for uploading material master in LSMW using RMDATIND direct input program..
    http://help.sap.com/bp_blv1500/BL_US/documentation/LSMW_EN_US.doc
    ~~Guduri

Maybe you are looking for