SAP Function BAPI_MATERIAL_SAVEDATA - Create and Change Material Master Data

Parameter Reference Type Length Default Optional Text
CLIENTDATA BAPI_MARA u 986 X Client-specific material data
CLIENTDATAX BAPI_MARAX u 131 X Information on update for CLIENTDATA
FLAG_CAD_CALL BAPIE1GLOBAL_DATA-TESTRUN C 1 SPACE X Call From CAD System
FLAG_ONLINE BAPIE1GLOBAL_DATA-TESTRUN C 1 SPACE X No ALE Field Selection
FORECASTPARAMETERS BAPI_MPOP u 47 X Forecast Parameters
FORECASTPARAMETERSX BAPI_MPOPX u 24 X Information on update for FORECASTDATA
HEADDATA BAPIMATHEAD u 118 Header segment with control information
NO_DEQUEUE BAPIE1GLOBAL_DATA-TESTRUN C 1 SPACE X Screens, display user entry
NO_ROLLBACK_WORK BAPIE1GLOBAL_DATA-TESTRUN C 1 SPACE X Override rollback if error occurs
PLANNINGDATA BAPI_MPGD u 118 X Planning data
PLANNINGDATAX BAPI_MPGDX u 10 X Information on update for PLANNINGDATA
PLANTDATA BAPI_MARC u 887 X Plant-specific material data
PLANTDATAX BAPI_MARCX u 173 X Information on update for PLANTDATA
SALESDATA BAPI_MVKE u 227 X Sales data
SALESDATAX BAPI_MVKEX u 48 X Information on update for SALESDATA
STORAGELOCATIONDATA BAPI_MARD u 48 X Storage-location-specific material data
STORAGELOCATIONDATAX BAPI_MARDX u 16 X Information on update for STORAGELOCATIONDATA
STORAGETYPEDATA BAPI_MLGT u 55 X Storage-type-specific material data
STORAGETYPEDATAX BAPI_MLGTX u 14 X Information on update for STORAGETYPEDATA
VALUATIONDATA BAPI_MBEW u 315 X Valuation data
VALUATIONDATAX BAPI_MBEWX u 61 X Information on update for VALUATIONDATA
WAREHOUSENUMBERDATA BAPI_MLGN u 89 X Warehouse-number-specific material data
WAREHOUSENUMBERDATAX BAPI_MLGNX u 31 X Information on update for WAREHOUSEDATA

Parameter Reference Type Length Text
RETURN BAPIRET2 u 548 Return parameters

Parameter Reference Length Optional Text
EXTENSIONIN BAPIPAREX 990 X Reference Structure for BAPI Parameters EXTENSIONIN/EXTENSIONOUT
EXTENSIONINX BAPIPAREXX 990 X Reference Structure for BAPI Parameters EXTENSIONIN/EXTENSIONOUT
INTERNATIONALARTNOS BAPI_MEAN 27 X International Article Numbers (EANs)
MATERIALDESCRIPTION BAPI_MAKT 44 X Material descriptions
MATERIALLONGTEXT BAPI_MLTX 222 X Long texts
PRTDATA BAPI_MFHM 69 X Production resource/tool (PRT) fields in the material master
PRTDATAX BAPI_MFHMX 28 X Information on update for PRTDATAX
RETURNMESSAGES BAPI_MATRETURN2 548 X All messages
TAXCLASSIFICATIONS BAPI_MLAN 51 X Tax classifications
UNITSOFMEASURE BAPI_MARM 106 X Units of measure
UNITSOFMEASUREX BAPI_MARMX 28 X Information on update for UNITSOFMEASURE

Functionality
You use this method to create new material master data or to changeexisting material master data. The data on a material can betransferred for each call.
When creating material master data, you must transfer the materialnumber, the material type, and the industry sector to the method. Youmust also enter a material description and its language.
When changing material master data, you need enter only the materialnumber.
In the header data, you must select at least one view for which data isto be created. Depending on the view selected, you must maintain otherrequired parameters. If you do not enter values for all of the requiredparameters, the method is ended with an error message.
The corresponding fields in the tables (such as CLIENTDATA) must firstbe supplied with data by the calling program. An indicator must also beset for each of these fields so that the data is written to thedatabase by the method. This requires the calling program to supply thecorresponding field with the indicator in a checkbox table (forexample, CLIENTDATAX). Checkbox tables exist for tables that do notcontain any language-dependent texts (MAKT, MLTX), InternationalArticle Numbers (MEAN), or tax classifications (MLAN). Several datarecords for a material can be created in these tables.
INCLUDE ISO OBJECT DOKU ID TX
If you want to maintain long texts (basic data texts, internalcomments, purchase order texts, material memos, or sales texts) orcustomer-defined fields for a material, some special conditions have tobe observed. They are described in the documentation for parametersMATERIALLONGTEXT and EXTENSIONIN.

Description
INCLUDE STRUKTUR OBJECT DOKU ID TX LANGUAGE EN
INCLUDE DE_DOKU OBJECT DOKU ID TX LANGUAGE EN
Since numerous information and error messages can occur while thematerial is being processed, the messages created are collected in thetable H_MESSAGES. The return parameter tells you only whether thematerial was created or changed successfully.
INCLUDE GRAVIEREND OBJECT DOKU ID TX LANGUAGE EN

Value range
Type,,ID,,Number,,Message
S,,MG,,537,,Messages for material &: Log number &
E,,MG,,537,,Messages for material &: Log number &

Description
You use this structure to transfer the general basic data on amaterial.
INCLUDE DE_DOKU OBJECT DOKU ID TX LANGUAGE EN

Notes
INCLUDE MUSSEINGABENALR OBJECT DOKU ID TX LANGUAGE EN
You need specify a unit of measure in the field PO_UNIT (orPO_UNIT_ISO) only if the order unit is not the same as the base unit ofmeasure (field BASE_UOM or BASE_UOM_ISO).
INCLUDE FOLG_FELDALR OBJECT DOKU ID TX LANGUAGE EN

  • BASE_UOM (or BASE_UOM_ISO)

  • PO_UNIT (or PO_UNIT_ISO)
  • Description
    This (checkbox) structure determines which fields in the assigned userdata structure (CLIENTDATA) contain change-relevant information.
    INCLUDE ANKREUZLEISTE OBJECT DOKU ID TX LANGUAGE EN
    INCLUDE BAPIUPDATE OBJECT DOKU ID TX LANGUAGE EN

    Example
    You want to change only the old material number for the material MAT01.
    The structure CLIENTDATA contains the following fields:

    • OLD_MAT_NO,,MAT01_OLD

    • The values contained in the remaining fields in structure CLIENTDATAare as required (in the simplest case, the values are the initialvalues).
      The structure CLIENTDATAX must then be as follows:
      • OLD_MAT_NO,,X

      • All other fields in the structure CLIENTDATAX must contain theirinitial values. The material number is contained in fieldHEADDATA-MATERIAL.

        Description
        You use this structure to transfer the forecast parameters for thematerial.
        INCLUDE DE_DOKU OBJECT DOKU ID TX LANGUAGE EN

        Description
        This (checkbox) structure is used to determine which fields in theassigned user data structure (FORECASTPARAMETERS) containchange-relevant information.
        INCLUDE ANKREUZLEISTE OBJECT DOKU ID TX LANGUAGE EN
        INCLUDE BAPIUPDATE OBJECT DOKU ID TX LANGUAGE EN

        Description
        The fundamental data necessary for maintaining a material is defined inthis structure. The fields essentially correspond to the fieldsavailable on the initial screen in dialog maintenance when creating amaterial master record.
        When creating material master data, you can create or change onlysingle materials in this structure.
        INCLUDE DE_DOKU OBJECT DOKU ID TX LANGUAGE EN

        Notes
        When you create material master data, the following fields must alwayscontain a value in the structure:

        • MATERIAL

        • Only external number assignment is supported for the material number(MATERIAL). If you want the material number to be assigned internally,the method BAPI_MATERIAL_GETINTNUMBER must first be called. This methoddetermines an internal number for the material to be created. You mustenter this internal number in field HEADDATA-MATERIAL.
          • IND_SECTOR

          • MATL_TYPE

          • When you change material master data, the field MATERIAL must alwayscontain a value in the structure.
            At least one view must be selected:
            • BASIC_VIEW (always necessary when creating material master data)

            • SALES_VIEW

            • PURCHASE_VIEW

            • MRP_VIEW

            • FORECAST_VIEW

            • WORK_SCHED_VIEW

            • PRT_VIEW

            • STORAGE_VIEW

            • WAREHOUSE_VIEW

            • QUALITY_VIEW

            • ACCOUNT_VIEW

            • COST_VIEW .

            • Corresponding update structures (for example, CLIENTDATAX, PLANTDATAX,etc.) also exist for individual user data structures (for example,CLIENTDATA, PLANTDATA, etc.). These update structures containinformation on which fields in the user data structure assigned arechange-relevant.

              Description
              You use this structure to transfer the planning data for the material.
              INCLUDE DE_DOKU OBJECT DOKU ID TX LANGUAGE EN

              Description
              This (checkbox) structure determines which fields in the assigned userdata structure (PLANNINGDATA) contain change-relevant information.
              INCLUDE ANKREUZLEISTE OBJECT DOKU ID TX LANGUAGE EN
              INCLUDE BAPIUPDATE OBJECT DOKU ID TX LANGUAGE EN

              Description
              You use this structure to transfer plant-specific data on the material.
              INCLUDE DE_DOKU OBJECT DOKU ID TX LANGUAGE EN

              Notes

              Description
              This (checkbox) structure determines which fields in the assigned userdata structure (PLANTDATA) contain change-relevant information.
              INCLUDE ANKREUZLEISTE OBJECT DOKU ID TX LANGUAGE EN
              INCLUDE BAPIUPDATE OBJECT DOKU ID TX LANGUAGE EN

              Description
              You use this structure to transfer the sales data for the material.
              INCLUDE DE_DOKU OBJECT DOKU ID TX LANGUAGE EN

              Description
              This (checkbox) structure determines which fields in the assigned userdata structure (SALESDATA) contain change-relevant information.
              INCLUDE ANKREUZLEISTE OBJECT DOKU ID TX LANGUAGE EN
              INCLUDE BAPIUPDATE OBJECT DOKU ID TX LANGUAGE EN

              Description
              You use this structure to transfer the storage-location-specific datafor the material.
              INCLUDE DE_DOKU OBJECT DOKU ID TX LANGUAGE EN

              Description
              This (checkbox) structure determines which fields in the assigned userdata structure (STORAGELOCATIONDATA) contain change-relevantinformation.
              INCLUDE ANKREUZLEISTE OBJECT DOKU ID TX LANGUAGE EN
              INCLUDE BAPIUPDATE OBJECT DOKU ID TX LANGUAGE EN

              Description
              You use this structure to transfer the storage-type-specific data forthe material.
              INCLUDE DE_DOKU OBJECT DOKU ID TX LANGUAGE EN

              Description
              This (checkbox) structure determines which fields in the assigned userdata structure (STORAGELOCATIONDATA) contain change-relevantinformation.
              INCLUDE ANKREUZLEISTE OBJECT DOKU ID TX LANGUAGE EN
              INCLUDE BAPIUPDATE OBJECT DOKU ID TX LANGUAGE EN

              Description
              You use this structure to transfer the valuation data for the material.
              INCLUDE DE_DOKU OBJECT DOKU ID TX LANGUAGE EN

              Description
              This (checkbox) structure determines which fields in the assigned userdata structure (VALUATIONDATA) contain change-relevant information.
              INCLUDE ANKREUZLEISTE OBJECT DOKU ID TX LANGUAGE EN
              INCLUDE BAPIUPDATE OBJECT DOKU ID TX LANGUAGE EN

              Description
              You use this structure to transfer the warehouse-number-specific datafor the material.
              INCLUDE DE_DOKU OBJECT DOKU ID TX LANGUAGE EN

              Description
              This (checkbox) structure determines which fields in the assigned userdata structure (WAREHOUSENUMBERDATA) contain change-relevantinformation.
              INCLUDE ANKREUZLEISTE OBJECT DOKU ID TX LANGUAGE EN
              INCLUDE BAPIUPDATE OBJECT DOKU ID TX LANGUAGE EN

              Description
              You use this structure to transfer the material's customer-definedfields. For information on transferring these fields, see the functionmodule documentation.

              Hinweis
              Besides the table fields already defined, customer-defined table fieldscan also be supplied with data. Since these fields are created by thecustomer, they are known only during the runtime and must therefore bedetermined dynamically.
              The structures BAPI_TE_ ( = MARA, MARC, MARD, MBEW, MLGN,MLGT, MVKE) and the relevant checkbox structures BAPI_TE_ (= MARAX, etc.) must first be extended by the customer to include thefields required. The standard structures contain only the correspondingkey fields. When including new fields in these structures, make surethat the field has the same name as the field in the database table. Inaddition, the fields in the structures BAPI_TE_ may only be ofthe type CHARACTER. The data element BAPIUPDATE must be used for thefields in the checkbox structure (except for key fields).
              The two parameters EXTENSIONIN and EXTENSIONINX are used to transferthe data to the method. The field STRUCTURE contains the name of thestructure (for example, BAPI_TE_MARA or BAPI_TE_MARAX) used to identifythe work area (for example, WA_BAPI_TE_MARA or WA_BAPI_TE_MARAX) towhich the data is transferred. The remaining fields for the parameterEXTENSIONIN or EXTENSIONINX contain the data for the key fields (forexample, the material number) and the data for the customer-definedfields. The number of characters reserved in the two parameters for thecontent of a customer-defined field must be the same as the number ofcharacters for the corresponding work area field. If the number ofcharacters required is smaller, the remaining characters in the twoparameters must be filled with blanks. Only then may the content ofanother field be transferred. Here too, remember that the data iswritten to the database only if the corresponding indicator has beenset in the work area.

              Description
              This (checkbox) structure is used to determine which fields in theassigned user data structure (EXTENSIONIN) contain change-relevantinformation.
              INCLUDE ANKREUZLEISTE OBJECT DOKU ID TX LANGUAGE EN
              INCLUDE BAPIUPDATE OBJECT DOKU ID TX LANGUAGE EN

              Description
              You use this structure to transfer the material's International ArticleNumbers (EANs).
              INCLUDE DE_DOKU OBJECT DOKU ID TX LANGUAGE EN
              Data on the main EAN and also on the alternative EANs is transferred inthis structure for each unit of measure. The main EAN is identified asthe EAN defined in field EAN_UPC in structure UNITSOFMEASURE for therelevant unit of measure.

              Notes
              If vendor-specific EANs are also used (see structure VENDOREAN), theymust be transferred in structure INTERNATIONALARTNOS in addition.
              INCLUDE UNITSOFMEASUREALR OBJECT DOKU ID TX LANGUAGE EN
              If you want to change the material's EANs (for example, the assignmentof main EANs), all assigned units of measure must also be transferredin structure UNITSOFMEASURE because this structure contains theinformation on which EAN is the main EAN for the corresponding unit ofmeasure.

              Description
              You use this structure to transfer the material descriptions.
              INCLUDE DE_DOKU OBJECT DOKU ID TX LANGUAGE EN

              Description
              You use this structure to transfer the long texts for the material.
              INCLUDE DE_DOKU OBJECT DOKU ID TX LANGUAGE EN

              Hinweis
              Different long texts (basic data texts, purchase order texts, internalcomments, sales texts, material memos) can be created for a material.This requires the fields APPLOBJECT, TEXT_NAME, TEXT_ID, and LANGU orLANGU_ISO in table parameter MATERIALLONGTEXT to contain entries.Depending on the content of field TEXT_ID, the field TEXT_NAME musthave the following structure:
              The material number is transferred first. If it has fewer than 18characters, the remaining characters must be filled with blanks. If itis a material memo (LTXT), the plant key must also be transferred fromcharacter 19 onwards; in the case of a sales text (0001), this must bethe sales organization and distribution channel. The combinationsallowed for the four different fields are indicated in the followingtable:
              APPLOBJECT,,TEXT_NAME,,,,TEXT_ID,,,,,,,,LANGU
              MATERIAL,,Matl no. (18 char.),,,,BEST, GRUN, or IVER,,,,Language
              MDTXT,,Matl no. (18 char.),,,,LTXT,,,,,,,,Language
              ,,Plant
              MVKE,,Matl no. (18 char.),,,,0001,,,,,,,,Language
              ,,Sales organization and
              ,,distribution channel

              Description
              You use this structure to transfer the production resource/tool datafor the material.
              INCLUDE DE_DOKU OBJECT DOKU ID TX LANGUAGE EN

              Description
              This (checkbox) structure determines which fields in the assigned userdata structure (PRTDATA) contain change-relevant information.
              INCLUDE ANKREUZLEISTE OBJECT DOKU ID TX LANGUAGE EN
              INCLUDE BAPIUPDATE OBJECT DOKU ID TX LANGUAGE EN

              Description
              This table is used to store messages processed by the method.
              INCLUDE DE_DOKU OBJECT DOKU ID TX LANGUAGE EN
              Since numerous information and error messages can occur while thematerial is being processed, the messages created are collected in thistable. The message processed last is transferred to the returnparameter (RETURN).

              Description
              You use this structure to transfer the tax classifications for thematerial.
              INCLUDE DE_DOKU OBJECT DOKU ID TX LANGUAGE EN

              Description
              You use this structure to transfer the units of measure for thematerial.
              INCLUDE DE_DOKU OBJECT DOKU ID TX LANGUAGE EN
              Both data on the base unit of measure and data on alternative units ofmeasure is transferred in this structure. The base unit of measure isidentified as the unit of measure defined in structure CLIENTDATA infield BASE_UOM (or BASE_UOM_ISO).

              Notes
              If an International Article Number (EAN) that does not yet exist in thesystem is transferred in field EAN_UPC, an entry in structureINTERNATIONALARTNOS must also be transferred for this new EAN.

              Description
              This (checkbox) structure determines which fields in the assigned userdata structure (UNITSOFMEASURE) contain change-relevant information.
              INCLUDE ANKREUZLEISTE OBJECT DOKU ID TX LANGUAGE EN
              INCLUDE BAPIUPDATE OBJECT DOKU ID TX LANGUAGE EN

1147949Missing authorization check for sales data
1549305NATO stock number cannot be maintained for manufacturer part
1538070Cannot create a "No Grid" material using IDOC or BAPI
1075141BAPIs valid for usage with AFS6.0
547351MM17:mass change price unit / ALE interface
1082864Creating a product group and lock in material master
951304MC86/MC84: Change/Create product group without MMZ2/MMZ1
908886MC84: No number range check when you create product groups
814673MC84: How to identify required fields (MG 144)
621753MC84: Error message when creating product group
631799MC84: Work scheduling view not created in MM02
592229MC84: Create product group with generated material number