To Extend material to plant using MATERIAL_MAINTAIN_DARK .

I am tryin to extend material into plants using MATERIAL_MAINTAIN_DARK  function module.Can someone please check the code below and tell me how i should modify it to work.Is BDC a better option?
DATA: t_amara_ueb LIKE mara_ueb OCCURS 0 WITH HEADER LINE.
DATA: t_amarc_ueb LIKE marc_ueb OCCURS 0 WITH HEADER LINE.
t_amara_ueb-mandt = sy-mandt.
t_amara_ueb-matnr = it_reqdata-material.
t_amara_ueb-tcode = 'MM01'.
t_amara_ueb-tranc = 1.
APPEND t_amara_ueb.
CLEAR t_amara_ueb.
t_amarc_ueb-mandt = sy-mandt.
t_amarc_ueb-matnr = it_reqdata-material.
t_amarc_ueb-werks = it_reqdata-plant.
t_amarc_ueb-tranc = 1.
t_amarc_ueb-KZKRI = 'X'.
APPEND t_amarc_ueb.
CLEAR t_amarc_ueb.
call function 'MATERIAL_MAINTAIN_DARK'
  exporting
  flag_muss_pruefen = 'X'
p_kz_no_warn = 'N'
kz_prf = space
kz_verw = 'X'
kz_aend = 'X'
kz_dispo = 'X'
  tables
   amara_ueb                       = t_amara_ueb
   AMARC_UEB                       = t_AMARC_UEB
EXCEPTIONS
   KSTATUS_EMPTY                   = 1
   TKSTATUS_EMPTY                  = 2
   T130M_ERROR                     = 3
   INTERNAL_ERROR                  = 4
   TOO_MANY_ERRORS                 = 5
   UPDATE_ERROR                    = 6
   OTHERS                          = 7
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
COMMIT WORK.
ENDIF.
Thanks and Regards,
Pratima.

Hi ,
Use the below code.
DATA : lt_mara_ueb TYPE TABLE OF mara_ueb INITIAL SIZE 0,
       lt_marc_ueb TYPE TABLE OF marc_ueb INITIAL SIZE 0,
       lt_errors TYPE TABLE OF merrdat INITIAL SIZE 0.
DATA : wa_mara_ueb TYPE mara_ueb,
       wa_marc_ueb TYPE marc_ueb,
       wa_messtab TYPE merrdat.
DATA : l_mstring(480).
parameters: l_matnr like mara-matnr.
* Set up I_MARA
REFRESH lt_mara_ueb.
wa_mara_ueb-mandt = sy-mandt.
wa_mara_ueb-tcode = 'MM01'.
wa_mara_ueb-matnr = l_matnr.
wa_mara_ueb-tranc = '0000000001'.
APPEND wa_mara_ueb TO lt_mara_ueb.
CLEAR wa_mara_ueb.
SELECT SINGLE * FROM marc INTO CORRESPONDING FIELDS OF wa_marc_ueb
WHERE matnr EQ l_matnr AND werks EQ '01FC'.
  IF sy-subrc EQ 0.
    MOVE '01BV' TO wa_marc_ueb-werks.
    wa_marC_ueb-tranc = '0000000001'.
    WA_MARC_UEB-PSTAT = SPACE.
    APPEND wa_marc_ueb TO lt_marc_ueb.
  ENDIF.
  CALL FUNCTION 'MATERIAL_MAINTAIN_DARK'
    EXPORTING
*   FLAG_MUSS_PRUEFEN               = 'X'
*   SPERRMODUS                      = 'E'
*   MAX_ERRORS                      = 0
      p_kz_no_warn                    = 'N'
      kz_prf                          = 'W'
*   KZ_VERW                         = 'X'
*   KZ_AEND                         = 'X'
*   KZ_DISPO                        = 'X'
*   KZ_TEST                         = ' '
*   NO_DATABASE_UPDATE              = ' '
*   CALL_MODE                       = ' '
*   CALL_MODE2                      = ' '
*   USER                            = SY-UNAME
*   SUPPRESS_ARRAY_READ             = ' '
*   FLG_MASS                        = ' '
* IMPORTING
*   MATNR_LAST                      =
*   NUMBER_ERRORS_TRANSACTION       =
    TABLES
      amara_ueb                       = lt_mara_ueb
*   AMAKT_UEB                       =
      amarc_ueb                       = lt_marc_ueb
*   AMARD_UEB                       =
*   AMFHM_UEB                       =
*   AMARM_UEB                       =
*   AMEA1_UEB                       =
*   AMBEW_UEB                       =
*   ASTEU_UEB                       =
*   ASTMM_UEB                       =
*   AMLGN_UEB                       =
*   AMLGT_UEB                       =
*   AMPGD_UEB                       =
*   AMPOP_UEB                       =
*   AMVEG_UEB                       =
*   AMVEU_UEB                       =
*   AMVKE_UEB                       =
*   ALTX1_UEB                       =
*   AMPRW_UEB                       =
*   AMFIELDRES                      =
*   AMERRDAT                        =
EXCEPTIONS
   KSTATUS_EMPTY                   = 1
   TKSTATUS_EMPTY                  = 2
   T130M_ERROR                     = 3
   INTERNAL_ERROR                  = 4
   TOO_MANY_ERRORS                 = 5
   UPDATE_ERROR                    = 6
   OTHERS                          = 7
  IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
  COMMIT WORK.
Regards,
Raghav

Similar Messages

  • Not able to extend material to plant 102

    Hi Experts,
    I have a problem to extend material.
    I am trying to extend material to plant 102, but when I click costing view I am getting error that "Valuation of Material 1288Z in valuation area 102 inconsistent"
    Please help me to resolve this
    Thanks in Advance,
    Regards,
    Vineela

    Hi Experts,
    In the material Master there is no Accounting View 1 and 2.
    How can I  get these views in material master.
    Regards,
    Vineela

  • Extend Material by Plant

    Hi Gurus,
    I need to extend large no of materials to other plant in the same sales org and distribution channel. If I have few materials can be extended to other plant each one  by going thru MM01, copy material from plant, sales org, dist channel.
    Kindly help me how to extend if large no of materials to be extended by plant?
    Regards,
    Vamsi.

    Hello Vamsi,
    There are many techniques available for changing data on a large basis for same parameters like CATT, MASS, LSMW, BDC.
    You can use transaction MASS and can give object type BUS1001001(material: retail) or BUS1001 Material:Industry) and execute.
    Then select the table MARC as you need to change Plant data and execute. Provide necessary information and execute.
    This transaction MASS updates information at table level. So ensure all the things before using the transaction.
    Regards,
    Priyanka

  • Extend material to plants

    Hello,
    I am trying to extend an existing material in several plants. I am using the BAPI, BAPI_MATERIAL_SAVEDATA. Now if I choose the purchasing view and pass plant related data, it extends the material but does not update certain fields like MRP controller,MRP profile,Availability check,loading group etc , even though I have marked all these fields X in MARCX structure.
    Also if I select all the data required and populate other views, if the material does not exist it gets created but if it exists in a plant and it needs to be extended into other plants it gives error material number xxxxx in version already exists for plant yyy.
    So basically the same program is being used for new materials and extending materials, if material number exists then extend to all plants else create in all plants. Getting error that the material already exists when trying to extend it.
    Please suggest.
    Regards,
    Sachin

    Hi,
    Did you check the fields in BAPIMATHEAD for extending the view.
    Check [this|http://forums.sdn.sap.com/search.jspa?threadID=&q=Extendmaterialtoaplant&objID=c42&dateRange=all&numResults=15&rankBy=10001]

  • Extend Material to Plant via IDOC

    I was under the assumption that I can create a material with my idoc type : J3AMAT and then extend that material to any plant I want using the same idoc given that I provide the plant data.  Is that correct or am I going crazy?

    If you are creating the Material via the SAP GUI with MM01 and simply enter the Basic Data1, Basic Data 2 data, the Material will create.  In the same SAP GUI session you then re-enter MM01 and attempt to create data for that new Material for tab "Sales: General/Plant Data".  SAP GUI will allow you to select a Plant, and if you have no data created for that Plant it will say that "The material already exists and will be extended".
    I wanted to replicate that same thing with the IDoc.  So I created the Material with only the Basic Data 1, and Basic Data 2 data via LSMW IDoc Matmas05.  Then using the same IDoc, I used the created Material Numbers and added the Plant Number I wished created to the Load File, along with all the data I had to add as a result of troubleshooting the missing data errors from repeated extension Idoc posting attempts.  Once I had all the data required for the Plant data, the Material was extended to the desired Plant.  I could go to MM03 and see it for that Material & Plant combo.  The only problem was that it took more fields than I thought.  That most likely has something to do with how the Material Master fields were configured I think.
    I did not need to create the Material & Plant data first, and then extend the Material & Plant data to a new Plant.  It was Material Master Basic Data to New Plant.

  • Problem in extending material master data using BAPI?

    Hi all,
    I have created a program to upload material master using BAPI_MATERIAL_SAVEDATA WITH VIEWS
    Basic view, purchase view, account view , storage view and MRP view. I am successful while uploading this data while not  taking  the valuation type  field to account view(passing only valuation area,valuation class and moving price).
    But when i am trying to pass valuation type field also then it is giving error as 'First create the valuation-type-independent data' .
    So i have written another program to extend this material to enter valuation type , then it is giving the error as 'Valuation category does not allow split valuation'.
    Please help me to solve this problem and while modifying what are the mandatory values to pass to BAPI?
    Thanks,
    Vamshi.

    Hi VAMSHI,
    I have your same error but I don't know how to solve it. We have active "material split valuation" and valuation type is mandatory field if using ACCOUNTING and COSTING views.
    Please, let me know.
    Thanks in advance.
    GB

  • How to extend material cross many plants using BAPI?

    Hi.
    when i use BAPI 'BAPI_MATERIAL_SAVEDATA' to extend material cross plants, i can not extent accounting view.
    code as below:
                BAPI_MARC-PLANT = IT_GOUJIAN-WERKS.
                BAPI_MARCX-PLANT = IT_GOUJIAN-WERKS.
                CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
                  EXPORTING
                    headdata            = BAPIMATHEAD
                   CLIENTDATA          = BAPI_MARA
                   CLIENTDATAX         = BAPI_MARAx
                    PLANTDATA           = BAPI_MARc
                    PLANTDATAX          = BAPI_MARcx
                   VALUATIONDATA       = BAPI_MBEW
                   VALUATIONDATAX      = BAPI_MBEWX
                  IMPORTING
                    RETURN              = IT_RETURN.
                 TABLES
                   MATERIALDESCRIPTION = IT_MATERIALDESC.
    i just change the plant data.
    any advice?

    You can extend the material in several plants using
    BAPI_MATERIAL_SAVEDATA
    All you need to do is populate the import parameter
    WA_HEADDATA-MATERIAL
    WA_HEADDATA-IND_SECTOR
    WA_HEADDATA-MATL_TYPE
    and check the views that you want to maintain in the new plant.
    Suppose you want to maintain only Basic view than..
    WA_HEADDATA-BASIC_VIEW = 'X'.
    And based on selected views , you need to populate other
    parameters.
    like I want to maintain basic view in another plant than
    I need to populate the plant data.
    WA_PLANTDATA-PLANT = <PLANT>.
    populate other fields, if required.
    WA_PLANTDATAX-PLANT = <PLANT>.
    populate flags, if required.
    and pass these parameters to the Function module.
    It should work.
    Please reward, if you find the answer useful.

  • How to extend material to new sto loc

    Hi All
    Let me know how to extend material to new storage location
    Tks
    Manju

    Dear,
    You can extend material for new storage location via MMSC.
    Ans if you want to extend list of material for storage location you can use MMSC_MASS.
    If you want to extend material for plant you can use MM01 - for single material and MM50 - For multiple materials.
    Regards,
    Mahesh Wagh

  • Extend material and customer to other sales areas

    can u please let me know?
    How to extend material and customer to other sales areas? To extend material one plant to another plant what are the configuration you done in your project?

    <b>To Extend Customer master: T.code - XD01:</b>
    In XD01, enter Account Group, Customer Code, Company Code, Sales Organization, Distribution Channel & Divission. Also ensure to maintain reference Customer, reference Company Code, reference Sales Organization, reference Distribution Channel & reference Division --> Enter. Most of the fields will be copied by default, but some fields will not be copied & they have to be maintained in the same manner how we create a new customer.
    <b>To Extend Material Master: T.Code - MM01:</b>
    In MM01, Enter the Material Code & reference Material Code --> Enter.
    Select the Tab pages to be maintained & go to organization data & maintain the details like Delivering Plant & Reference plant, Storage location & reference storage location, Sales Organization & reference Sales Organization, Distribution Channel & reference Distribution channel & so on ...  --> Enter. Most of the fields will be copied by default, but some fields will not be copied & they have to be maintained in the same manner how we create a new material.
    Regards,
    Rajesh Banka
    reward point if helpful.

  • Extend material master data from one plant to another plant

    hi,
    how can i extend material master data from one plant to another plant.
    is there any sap standard transaction for this ie. bdc/t-code.
    thanks in advance.......
    rahul

    Hi
    If you want to extend the material form one plant to another then below are the possible options.
    1) MM01 - Use the material in the reference and fill in copy from and to then press enter to complete the extention.This is recommended only if you want to extend very less records.
    2) Use LSMW and record MM01 thru BDC recording available in LSMW and make the template in excel and convert it to .txt tab delimited format to upload more records.LSMW is the perfect tool and is used extensively in all the projects.
    3) Get the help from ABAPer to create upload program and include the BDC recording.
    There is no standard T code available in SAP becoz data mainatenance in the material master will be based on the industry.
    Hope it will help.
    Thanks/Karthik

  • BAPI - To extend material to other plants (z program).

    Dear Friends,
    Please help to know the relevant BAPI can be used for below requirement:
    Material created one plant (Plant1).
    Same has to be extended to other plants (Plant2 & Plant3). Including price and all other data as is needs to be extended. I need to create u2018zu2019 transaction. Please help to know the correct BAPI that I can use.
    Thanks in advance for your help.
    Best regards,
    Lainel.

    Dear Wolfgang Valtin,
    You are right.
    Tested, Working fine.
    Thank you verymuch for your help.
    Resolved my query. Given points- 10.
    Thanks & Regards,
    Lainel.

  • Extend material to another plant

    hi all,
    I want to extend materials to another plant using copy from...  Someone knows  which BAPI  Can I  use
    to do  this?
    thanks.
    marisol

    u can use "BAPI_MATERIAL_SAVEDATA".
    Suppose u have to Extend material from 1000 to 1100 plant.
    so ur template will be like this:
    Material Number,Current_Plant,extend_plant,valuation area ,Type
    Using Material Number,Current_Plant , valuation arear , Type and pass it to
    BAPI_MATERIAL_GET_DETAIL
    u will get all data 4 , BAPI_MATERIAL_SAVEDATA.

  • Extending material master for different sales org/plant combination

    hi ,
    1 ) a material can be sold from one plant by many sales organisations. so we map this scenario in enterprise structure by the config step "assign sales org--dist channel--
    plant ". (let's say sales org A and B  selling from plant 1 and also sales org A selling from plant 2)
    when we have defined the above config step, then why we need to have material master extended for different combination of sales org and plant as in stpe 1 ?. we can just create one material master with one plant and sales org combination and based on config as in step one, we can sell material from any sales org from a plant  ?
    2) we can extend  material master for any combination of sales org/plant .....is it also possible to extend material master to different storage locations !
    regds
    pamela
    Edited by: Pamela79 on Feb 15, 2011 11:02 AM

    There are several reasons why you should extend the materails to different sales organizations and plants.
    a. The materials are normally valuated at the plant level. So, you can have different valuations at different plants.
    b. You can have different quantity stored in different plants. How do you know which plant has what quantity.
    c. You can have materail not to be sold from one plant, but you can have the same materail sold from the other, how do you block it? at the plant and materail combination, you can do it.
    d. For different sales organizations, you may want the cost and the price to be posted to different GL accounts. You can control it at sales org level of the materail.
    e. You may just want the material to be purchased but not sold, then you may not even create a sales org view for the material. But say, in future you will like to only purchase a materail from a plant and consume it for some other purpose but not sales (which u did previously), then you can block it at sales org and dbr level.
    So, these are a few reasons. But there could be many. You can have a look at the fields in the material master at sales org level and plant level and you can find it for yourself howmany parameters are there to control...
    Hope this helps...
    Regards,
    Mukund S

  • Extend Material to another plant with Valuation CAtegory X

    Hi All,
    I have a Material in Plant 1, with Valuation Category H.
    I want to extend this material to Plant 2 with Valuation Category 'X' (Auto Batch)
    Its not accepting X, any other entry would be possible
    It says "With Single batch valuation, batch management must be defined. The following plants have no batch management requirement: Plant 1"
    If i activate batch management in Plant 2, it is working.....but i dont want Batch management for this material.
    How do i solve this.
    Pls help.
    Thanks

    Hi,
    We can not remove Batch management thru MM02, once it is set in MM01. Its a gray field.
    can any one let me know whats the reason for not accepting valuation category x while extending the material?

  • Extending Materials one plant to another plant

    Dear Friends
    while extending material through LSMW to another plant  we facing problem :
    Sales : Sales Org 1 showing more fields mandatory like  1,valid from;  2. X-distr Chain Status  3. Sales Unit of Mesasure etc.  LSMW programme was OK   i did more times through this programme to extended. i maintained the below fields only in LSMW.  BUT while i extending material through MM01 there is no problems showing.  please advice how to solve this.  i want to extend more than 10K material in to new plants.
    TABNAME     Table Name
    TCODE     Transaction Code
    MATNR     Material
    MBRSH     Industry sector
    MTART     Material Type
    WERKS     Plant
    LGORT     Storage Location
    VKORG     Sales Organization
    VTWEG     Distribution Channel
    MAKTX     Material Description (Short Text)
    SKTOF     Cash discount indicator
    MTPOS     Item category group from material master
    MTVFP     Checking Group for Availability Check
    LADGR     Loading Group
    PRCTR     Profit Center
    DISGR     MRP Group
    DISMM     MRP Type
    DISLS     Lot size (materials planning)
    PERKZ     Period Indicator
    BKLAS     Valuation Class
    PEINH     Price Unit
    VERPR     Moving Average Price/Periodic Unit Price
    EKALR     Material Is Costed with Quantity Structur
    HKMAT     Material-related origin
    LOSGR     Lot Size for Product Costing

    if you used this program successfully before, and now it is complaining about new mandatory fields, then I would say that someone has changed the field selection for your material masters.
    Try to extend one material (that making problems in LSMW) using the manual way with MM01. LSMW does not really do anything different, so I expect that you face the problems with MM01.
    Then you either need to ask to the person who changed the settings  to reset them or you need to extend your LSMW  so that it can run with the new settings.

Maybe you are looking for

  • About the BSP:How should i handle the exception

    <b>Web is below:</b> Error when processing your request <b>What has happened?</b> The URL http://sapcidev01.autodesk.com:8000/sap/bc/bsp/sap/zixos_test/result.htm was not called due to an error.    Note The following error text was processed in the s

  • Problem: unable to view recordset in browser.

    I have an ASP page and when testing the recordset, a record is returned. (except for one record within the row which is a text value/format). But when viewing in the browser only table headings are shown and no records are displayed. process; user lo

  • Easy vpn or site-to-site vpn for back up connection?

    Hi, All of my remote sites are connected to HQ via MPLS circuits. I would like to create back link for those remote sites using 871 routers with DSL connection and terminate ipsec vpn tunnels at the outside interface of ASA5540 located at HQ. The 871

  • To reduce execution time of a Business Objects Dataservices job.

    The  issue that we are facing- Our goal-  To compare a record from a file  with 422928 records from another table on basis of  name & country, if a match is found then you take some specific columns of that matched record (from the table ) as our oup

  • CDR-21605: Failed while processing Module Component % in function c

    I'm generating a form with designer 6i (status 6.5.69.1.0 configuration 4.012). My form is a tabular form, every tab has the subcomponents that refer to previous tab. When I create the last subcomponent, exactly the 5th, and I generate, designer give