BAPI or FM to copy Material (MM01)?

Dear Experts,
I am finding difficult to locate a BAPI or FM that would create a New Material referencing a Old Material. This facility is provided by MM01. I managed to locate few BAPI's but they don't have a interface to capture the Old Material.
1. /AFS/BAPI_MATERIAL_SAVEDATA
2. BAPI_MATERIAL_SAVEREPLICA
3. BAPI_MATERIAL_SAVEDATA
If you find a BAPI or FM please pass it on. If you could include some sample data.
Thanks,
Sri

Dear  Gautham,
Thanks for the FM. But this FM does not provide the requirement I need.
When I mean Old Material it is not MARA-BISMT. What I mean is Create a New Material Referencing another Material.
Thanks
Sri

Similar Messages

  • Dumpp Error while creating material MM01

    Hi,
    While creating the material (mm01) i am getting dump error not allowing to save, 
    Message type: MESSAGE_TYPE_X_TEXT
    I checked the PPO setting it is active for BP type.
    Pls tell me how to solve this issue.
    Thanks

    Dear Rakesh,
    Go to Tr. code. ST22 and analysis the  cause
    From initial its seems  thatthere is a Text Field which  might be mandatory and  due to that syestem giving dump, Chek wth  ur abaper

  • Creation of material using BAPI in LSMW without using material no.

    Hi SAP Gurus,
    I have a requirement of creating materials using the BAPI in LSMW.
    I tried to create a material using the BAPI (Business Object - BUS1001006 , and method - SAVEDATA) which should be created internally, but it is asking the material number to be given externally and my configuration is setup to create the material number internally.
    Even I looked into the material type which is associated with the number range and everything looks good.
    Is there any solution to create the material by using BAPI in LSMW without passing the material no. externally ?
    Appreciate your help.
    Kalikonda.

    Hi,
    it looks like it's not possible to call this BAPI wihtout material number. Here is a quote from BAPI documentation.
    When creating material master data, you must transfer the material
    number, the material type, and the industry sector to the method. You
    must also enter a material description and its language.
    Cheers

  • How do I highlight and copy material from one document to another by using keyboard commands? The tool bar is not appearing as it typically does.

    How do I copy material from one document to the next by using keyboard commands.  I am copying from Word into and external database and the external system seems to be covering my tool bar from which I would typically click editing shortcut commands.

    Highlight what you want to copy, then command - C. To paste, select where you want it to go, then command - V.

  • Bapi or FM to mark material for deletion

    Hi all,
    Is there a bapi or FM to mark material for deletion that we do through MM06.
    Let me know and i would appreciate if some could me that piece of bapi's code
    Thanks
    Preeti

    This should be all you need.
    report zrich_0003 .
    data: headdata type bapimathead.
    data: clientdata type bapi_mara.
    data: clientdatax type bapi_marax.
    data: return type  bapiret2 .
    data: returnm type table of bapi_matreturn2 with header line.
    data: xmara type mara.
    parameters: p_matnr type mara-matnr.
    select single * from mara into xmara
              where matnr = p_matnr.
    headdata-material        = xmara-matnr.
    headdata-ind_sector      = xmara-mbrsh.
    headdata-matl_type       = xmara-mtart.
    headdata-basic_view = 'X'.
    clientdata-del_flag =  'X'.
    clientdatax-del_flag = 'X'.
    call function 'BAPI_MATERIAL_SAVEDATA'
         exporting
              headdata       = headdata
              clientdata     = clientdata
              clientdatax    = clientdatax
         importing
              return         = return
         tables
              returnmessages = returnm.
    check sy-subrc  = 0.
    Regards,
    Rich Heilman

  • Can I copy MATERIAL adapter object and create new business object in R3AC1

    Hi experts,
    I need to copy MATERIAL adapter object and create a new business object R3AC1.
    Please let me know whether this is feasible.
    Thanks & Regards,
    Keya

    Usually  when there is a need to change/create an adapter object, I suggest to change object class to CUSTOMIZING in R3AC1. Then save it and call transaction R3AC3. There do necessary changes and afterwards switch back to original object class. There is no copy functionality for adapter objects. Kindly use transaction R3AC3 to create a new adapter object and maintain all tabs according to your requirements. When you are finished, kindly change the object class "CUSTOMIZING" to the original class name you're copying and the new adapter object will be visible in R3AC1.
    Documentation can be found in
       https://service.sap.com/ce    -> Early Product Training         > SAP CRM 4.0 & mySAP CRM Edition 2004 .. on the learning map, please choose "Development Consultant" -> Open "Enhance CRM Scenarios"
    Here you can find a lot of guides and SAP tutors on how to create an adapter object, example coding, and so on.
    To enable Filter Fields for an Adapter object make requisite changes in table SMOFFILFLD and generate the Adapter Object using SMOGGEN. CHeck table CRMPAROLTP in ECC to enable Filtering

  • BAPI or RFC to create material

    Hi folks,
            Could any one tell me, if there is any BAPI or RFC to create Material in Material master....if so pls tel me the name and how to use the BAPI...thanks in advance,
                              santosh.

    HI CHECK OU THIS PROGRAM
    *& Report  ZBAPI_MATERIAL_SAVEDATA
    **& AUTHOR *
    *& PURPOSE : THIS REPORT USES BAPI MATERIAL SAVE DATA TO UPDATE AND CREATE
    *&           THE MATERIAL
    REPORT  ZBAPI_MATERIAL_SAVEDATA NO STANDARD PAGE HEADING MESSAGE-ID (ZHNC).
    TYPES:BEGIN OF TY_MAT,
           MATERIAL(4),
           IND_SECTOR(1),
           MATL_TYPE(4),
          BASIC_VIEW(1),*
          SALES_VIEW(1),*
          PURCHASE_VIEW(1),*
          STORAGE_VIEW(1),*
           MATL_GROUP(9),
           BASE_UOM(3),
           BASE_UOM_ISO(3),
          MATL_GROUP1(1),*
          BASE_UOM1(1),*
          BASE_UOM_ISO1(1),*
           PLANT(4),
           DEL_FLAG(1),
           PUR_GROUP(3),
           BASE_QTY(13),
          PLANT2(4),*
          DEL_FLAG5(1),*
          PUR_GROUP1(1),*
          BASE_QTY1(1),*
          PLANT3(4),*
           STGE_LOC(4),
           MRP_IND(1),
          PLANT4(4),*
          STGE_LOC1(4),*
          MRP_IND1(1),*
           SALES_ORG(4),
           DISTR_CHAN(2),
           DEL_FLAG1(1),
           MIN_ORDER(13),
          SALES_ORG1(4),*
          DISTR_CHAN1(2),*
          DEL_FLAG2(1),*
          MIN_ORDER1(1),*
           LANGU(2),
          MATL_DESC(40),
       END OF TY_MAT.
    DATA: IT_DATA TYPE TABLE OF TY_MAT,
          WA_DATA LIKE LINE  OF IT_DATA.
    *decalraing flag
    data: v_flag value ''.
    *DECLARING WORK AREAs  TO BE PASSED TO THE FUNCTION MODULE.
    DATA: BAPI_HEAD LIKE BAPIMATHEAD,
          BAPI_CLIENTDATA LIKE BAPI_MARA,
          BAPI_CLIENTDATAX LIKE BAPI_MARAX,
          BAPI_PLANTDATA LIKE BAPI_MARC,
          BAPI_PLANTDATAX LIKE  BAPI_MARCX,
          BAPI_STORAGELOCATIONDATA LIKE BAPI_MARD,
          BAPI_STORAGELOCATIONDATAX LIKE BAPI_MARDX,
          BAPI_SALESDATA LIKE BAPI_MVKE,
          BAPI_SALESDATAX LIKE BAPI_MVKEX,
          BAPI_MAKT LIKE BAPI_MAKT,
          BAPI_RETURN LIKE BAPIRET2.
    *INTERNAL TABLE TO HOLD THE MATERIAL DESCRIPTION
    DATA: BEGIN OF IT_MAKT OCCURS 0.
    INCLUDE STRUCTURE BAPI_MAKT.
    DATA END OF IT_MAKT.
    DATA:BEGIN OF IT_RET OCCURS 0.
    INCLUDE STRUCTURE BAPIRET2.
    DATA END OF IT_RET.
    *INTERNAL TABLE TO HOLD HEADER DATA
    DATA: IT_EXCEL TYPE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.
    *SELECTION-SCREEN ELEMENTS
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    PARAMETER: FNAME TYPE RLGRAP-FILENAME OBLIGATORY DEFAULT 'C:\Documents and Settings\Administrator\Desktop\MATMAS.XLS' .
    PARAMETERS: P_BEGCOL TYPE I DEFAULT 1 NO-DISPLAY,
                P_BEGROW TYPE I DEFAULT 1 NO-DISPLAY,
                P_ENDCOL TYPE I DEFAULT 100 NO-DISPLAY,
                P_ENDROW TYPE I DEFAULT 32000 NO-DISPLAY.
    SELECTION-SCREEN END OF BLOCK B1.
    *DECLARATION OF EXCELAL TABLE
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR FNAME.
    PERFORM F_GET_FILE USING FNAME.
    START-OF-SELECTION.
    PERFORM F_XLS_ITAB USING FNAME
                       CHANGING IT_EXCEL.
    PERFORM F_MOVE_DATA.
    perform F_GET_DATA.
    *&      Form  F_GET_FILE
          text*
         -->P_FNAME  text*
         <--P_SY_SUBRC  text*
    FORM F_GET_FILE  USING    P_FNAME LIKE FNAME.
    CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
    EXPORTING
       PROGRAM_NAME        = SYST-REPID
       DYNPRO_NUMBER       = SYST-DYNNR
      FIELD_NAME          = ' '*
      STATIC              = ' '*
      MASK                = ' '*
      CHANGING
        FILE_NAME           = P_FNAME
    EXCEPTIONS*
      MASK_TOO_LONG       = 1*
      OTHERS              = 2*
    IF SY-SUBRC <> 0.
    MESSAGE E006(ZHNC).
    ENDIF.
    ENDFORM.                    " F_GET_FILE
    *&      Form  F_XLS_ITAB
          text*
         -->P_FNAME  text*
         <--P_IT_EXCEL  text*
    FORM F_XLS_ITAB  USING    P_FNAME
                     CHANGING P_IT_EXCEL.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      EXPORTING
        FILENAME                      = FNAME
        I_BEGIN_COL                   = P_BEGCOL
        I_BEGIN_ROW                   = P_BEGROW
        I_END_COL                     = P_ENDCOL
        I_END_ROW                     = P_ENDROW
      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.*
    ENDIF.
    ENDFORM.                    " F_XLS_ITAB
    *&      Form  F_MOVE_DATA
          text*
    -->  p1        text*
    <--  p2        text*
    FORM F_MOVE_DATA .
    DATA : LV_INDEX TYPE I.
    FIELD-SYMBOLS <FS>.
    *--- Sorting the internal table
    SORT IT_EXCEL BY ROW COL.
    CLEAR IT_EXCEL.
    LOOP AT IT_EXCEL.
    MOVE IT_EXCEL-COL TO LV_INDEX.
    *--- Assigning the each record to an internal table row
    ASSIGN COMPONENT LV_INDEX OF STRUCTURE WA_DATA TO <FS>.
    *--- Asigning the field value to a field symbol
    MOVE IT_EXCEL-VALUE TO <FS>.
    AT END OF ROW.
    APPEND WA_DATA TO IT_DATA.
    CLEAR WA_DATA.
    ENDAT.
    ENDLOOP.
    ENDFORM.                    " F_MOVE_DATA
    *&      Form  F_GET_DATA
          text*
    -->  p1        text*
    <--  p2        text*
    FORM F_GET_DATA .
    LOOP AT IT_DATA INTO WA_DATA.
    MOVE-CORRESPONDING WA_DATA  TO  BAPI_HEAD.
    BAPI_HEAD-BASIC_VIEW ='X'.
    BAPI_HEAD-SALES_VIEW ='X'.
    BAPI_HEAD-PURCHASE_VIEW ='X'.
    BAPI_HEAD-STORAGE_VIEW ='X'.
    MOVE-CORRESPONDING WA_DATA TO BAPI_CLIENTDATA.
    BAPI_CLIENTDATAX-MATL_GROUP = 'X'.
    BAPI_CLIENTDATAX-BASE_UOM = 'X'.
    BAPI_CLIENTDATAX-BASE_UOM_ISO = 'X'.
    MOVE-CORRESPONDING WA_DATA TO BAPI_PLANTDATA.
    BAPI_PLANTDATAX-PLANT = BAPI_PLANTDATA-PLANT.
    BAPI_PLANTDATAX-DEL_FLAG = 'X'.
    BAPI_PLANTDATAX-PUR_GROUP = 'X'.
    BAPI_PLANTDATAX-BASE_QTY = 'X'.
    MOVE-CORRESPONDING WA_DATA TO BAPI_STORAGELOCATIONDATA.
    BAPI_STORAGELOCATIONDATA-PLANT = BAPI_PLANTDATA-PLANT.
    BAPI_STORAGELOCATIONDATAX-PLANT = BAPI_STORAGELOCATIONDATA-PLANT.
    BAPI_STORAGELOCATIONDATAX-STGE_LOC = BAPI_STORAGELOCATIONDATA-STGE_LOC.
    BAPI_STORAGELOCATIONDATAX-MRP_IND = 'X'.
    MOVE-CORRESPONDING WA_DATA TO BAPI_SALESDATA.
    BAPI_SALESDATAX-SALES_ORG = BAPI_SALESDATA-SALES_ORG.
    BAPI_SALESDATAX-DISTR_CHAN = BAPI_SALESDATA-DISTR_CHAN.
    BAPI_SALESDATAX-DEL_FLAG = BAPI_SALESDATA-DEL_FLAG.
    BAPI_SALESDATAX-MIN_ORDER = 'X'.
    REFRESH IT_MAKT.
    IT_MAKT-LANGU = WA_DATA-LANGU.
    IT_MAKT-MATL_DESC = WA_DATA-MATL_DESC.
    APPEND IT_MAKT.
    CLEAR IT_RET.
    REFRESH IT_RET.
    PERFORM F_CALL_BAPI.
    READ TABLE IT_RET WITH KEY TYPE = 'S'.
    IF SY-SUBRC EQ 0.
    PERFORM F_BAPI_COMMIT.
    WRITE:/ 'MATERIAL CREATED OR UPDATED SUCESSFULLY WITH MATERIAL NO',WA_DATA-MATERIAL.
    ELSE.
    MESSAGE E000(ZHNC) WITH 'ERROR IN CREATING THE MATERIAL'.
    *WRITE: / 'ERROR IN CREATIN MATERIAL',IT_RET-MESSAGE.
    *PERFORM F_DOWNLOAD.
    ENDIF.
    *ENDIF.
    ENDLOOP.
    ENDFORM.                    " F_GET_DATA
    *&      Form  F_CALL_BAPI
          text*
    -->  p1        text*
    <--  p2        text*
    FORM F_CALL_BAPI .
    CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
      EXPORTING
        HEADDATA                   = BAPI_HEAD
       CLIENTDATA                 =  BAPI_CLIENTDATA
       CLIENTDATAX                =  BAPI_CLIENTDATAX
       PLANTDATA                  =  BAPI_PLANTDATA
       PLANTDATAX                 =  BAPI_PLANTDATAX
       STORAGELOCATIONDATA        =  BAPI_STORAGELOCATIONDATA
       STORAGELOCATIONDATAX       =  BAPI_STORAGELOCATIONDATAX
       SALESDATA                  =  BAPI_SALESDATA
       SALESDATAX                 =  BAPI_SALESDATAX
    IMPORTING
       RETURN                     =  IT_RET
    TABLES
       MATERIALDESCRIPTION        = IT_MAKT
      UNITSOFMEASURE             =*
      UNITSOFMEASUREX            =*
      INTERNATIONALARTNOS        =*
      MATERIALLONGTEXT           =*
      TAXCLASSIFICATIONS         =*
      RETURNMESSAGES             =*
      PRTDATA                    =*
      PRTDATAX                   =*
      EXTENSIONIN                =*
      EXTENSIONINX               =*
    APPEND IT_RET.
    ENDFORM.                    " F_CALL_BAPI
    *&      Form  F_BAPI_COMMIT
          text*
    -->  p1        text*
    <--  p2        text*
    FORM F_BAPI_COMMIT .
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING*
      WAIT         =*
    IMPORTING*
      RETURN        =*
    ENDFORM.                    " F_BAPI_COMMIT
    IF U WANT THE EXCEL FILE I CAN SEND U
    PLZ REWARD POINTS TO HELP ANSWERS

  • Imp of division while creating  Material mm01

    hi guys
                While creating material (mm01) there is option of puting  Div ,and if  v put com div  insted of actual div in material ,Now  while creating  sales order  if v put same material it gives option of various sales area .and we can choos any division along with com div also .
    now my question is when 1 product is assigned or related to 1 division only then wht use of creating com division, wht is d purpose ,
    while creating material specific div we shd  put insted of com div
    plse explain me  if i am wrong 
    and  wht use  of creating  com div here
    thnx
    point ll be rewarded if ans is helpful

    The common division is ideally used for all the products where you do not need to restrict the same to any Sales areas.
    If you want a product to be funcuanally operating in all the sales areas of your comapny code then you assign the same to the Common DIv.
    regards,
    Amlan

  • Copy Material Codes, Costs, and Cost Code Distribution

    Has any one come up with way to copy material codes with their unit prices and cost code distributions from one project(or template) to another? When a user has a large inventory of material codes, it would be helpful to be able to copy, or import these to a new project.
    Thanks for any help.

    Forgot to mention that CMPlus will copy Materials from one project to another with the unit pricing of the current project HOWEVER, the cost distribution is tied to the contract that the material is associated with. If you are using materials with Daily Reports to track material not related to a contract then this will be all you need. IF you are using Materials in association with line items on a contract/PO then it will populate the selection list but you will need to perform more data entry to properly link to the contract.
    By performing this copy from one project to the other the capability to "Generate" materials from a contract or PO is no longer functional because the Material already exists as far a Contract Manager is concerned
    One more item to think about - materials can only be associated with one contract - that does not mean that a material can not be used on more than one contract.
    I am assuming that since you are asking this question that you have been using materials on your projects and understand the nuances and issues with the way CM handles Materials.

  • How to create material(mm01)  through function module or bapi

    Hi,
        this is kiran iam sap fresher.

    Hi,
    try this
    *& Report ZKAR_MATMAS_BAPI
    *& This program demonstrates how easy it is to create Material master
    *& data using BAPI_MATERIAL_SAVEDATA
    *& The program also generates a report post-execution displaying errors
    *& as well as successful uploads
    REPORT ZKAR_MATMAS_BAPI.
    * TABLES
    * FLAGS *
    DATA: F_STOP. " Flag used to stop processing
    * DATA DECLARATIONS *
    DATA : V_EMPTY TYPE I, " No. of empty records
    V_TOTAL TYPE I. " Total no. of records.
    * STRUCTURES & INTERNAL TABLES
    *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_MARC1 LIKE BAPI_MARC, " Plant View
    BAPI_MARCX LIKE BAPI_MARCX, " Checkbox Structure for BAPI_MARC
    BAPI_MBEW1 LIKE BAPI_MBEW, " Accounting View
    BAPI_MBEWX LIKE BAPI_MBEWX, " Checkbox Structure for BAPI_MBEW
    BAPI_RETURN LIKE BAPIRET2. " Return Parameter
    *--- Internal table to hold excel file data
    DATA: IT_INTERN TYPE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.
    *--- Internal table to hold Matetrial descriptions
    DATA: BEGIN OF IT_MAKT OCCURS 100.
            INCLUDE STRUCTURE BAPI_MAKT.
    DATA: END OF IT_MAKT.
    *--- Internal to hold the records in the text file
    DATA : BEGIN OF IT_DATA 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 IT_DATA.
    * SELECTION SCREEN. *
    SELECTION-SCREEN BEGIN OF BLOCK SCR1 WITH FRAME TITLE TEXT-111.
    PARAMETER : P_FILE TYPE RLGRAP-FILENAME OBLIGATORY DEFAULT " Input File
    'C:\Material_master.XLS'.
    PARAMETER : P_MAX(4) OBLIGATORY DEFAULT '100'. " no.of recs in a session
    PARAMETERS: P_HEADER TYPE I DEFAULT 0. " Header Lines
    PARAMETERS: P_BEGCOL TYPE I DEFAULT 1 NO-DISPLAY,
    P_BEGROW TYPE I DEFAULT 1 NO-DISPLAY,
    P_ENDCOL TYPE I DEFAULT 100 NO-DISPLAY,
    P_ENDROW TYPE I DEFAULT 32000 NO-DISPLAY.
    SELECTION-SCREEN END OF BLOCK SCR1.
    * AT SELECTION-SCREEN *
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
    *--- Validating file
      PERFORM VALIDATE_FILE USING P_FILE.
    * START-OF-SELECTION
    START-OF-SELECTION.
    *--- Perform to convert the Excel data into an internal table
      PERFORM CONVERT_XLS_ITAB.
      IF NOT IT_DATA[] IS INITIAL.
    *--- Perform to delete Header lines
        PERFORM DELETE_HEADER_EMPTY_RECS.
      ENDIF.
    * END OF SELECTION. *
    END-OF-SELECTION.
    *--- Perform to upload Material Master data
      PERFORM UPLOAD_MATMAS.
    * Form : validate_input_file
    * Description : To provide F4 help for file if read from PC
    FORM VALIDATE_FILE USING F_FILE TYPE RLGRAP-FILENAME.
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
        CHANGING
          FILE_NAME     = F_FILE
        EXCEPTIONS
          MASK_TOO_LONG = 1
          OTHERS        = 2.
      IF SY-SUBRC <> 0.
        MESSAGE S010(ZLKPL_MSGCLASS). " 'Error in getting filename'.
      ENDIF.
    ENDFORM. " validate_input_file
    *& Form CONVER_XLS_ITAB
    * text
    FORM CONVERT_XLS_ITAB.
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          FILENAME    = P_FILE
          I_BEGIN_COL = P_BEGCOL
          I_BEGIN_ROW = P_BEGROW
          I_END_COL   = P_ENDCOL
          I_END_ROW   = P_ENDROW
        TABLES
          INTERN      = IT_INTERN.
      IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *--- Perform to move the data into an internal data
      PERFORM MOVE_DATA.
    ENDFORM. " CONVERT_XLS_ITAB
    *& Form MOVE_DATA
    * text
    FORM MOVE_DATA.
      DATA : LV_INDEX TYPE I.
      FIELD-SYMBOLS <FS>.
    *--- Sorting the internal table
      SORT IT_INTERN BY ROW COL.
      CLEAR IT_INTERN.
      LOOP AT IT_INTERN.
        MOVE IT_INTERN-COL TO LV_INDEX.
    *--- Assigning the each record to an internal table row
        ASSIGN COMPONENT LV_INDEX OF STRUCTURE IT_DATA TO <FS>.
    *--- Asigning the field value to a field symbol
        MOVE IT_INTERN-VALUE TO <FS>.
        AT END OF ROW.
          APPEND IT_DATA.
          CLEAR IT_DATA.
        ENDAT.
      ENDLOOP.
    ENDFORM. " MOVE_DATA
    *& Form DELETE_HEADER_EMPTY_RECS
    * To delete the Header and empty records
    FORM DELETE_HEADER_EMPTY_RECS.
      DATA: LV_TABIX LIKE SY-TABIX.
      IF NOT P_HEADER IS INITIAL.
        LOOP AT IT_DATA.
          IF P_HEADER > 0 AND NOT IT_DATA IS INITIAL.
            DELETE IT_DATA FROM 1 TO P_HEADER.
    * P_HEADER = 0.
            EXIT.
          ENDIF.
        ENDLOOP.
      ENDIF.
      CLEAR IT_DATA.
    *--- To delete the empty lines from internal table
      LOOP AT IT_DATA.
        LV_TABIX = SY-TABIX.
        IF IT_DATA IS INITIAL.
          V_EMPTY = V_EMPTY + 1.
          DELETE IT_DATA INDEX LV_TABIX..
        ENDIF.
      ENDLOOP.
      CLEAR IT_DATA.
    *--- Total no of recs in file
      DESCRIBE TABLE IT_DATA LINES V_TOTAL.
      IF V_TOTAL = 0.
        MESSAGE I013(ZLKPL_MSGCLASS). " No records in the file
        F_STOP = 'X'.
        STOP.
      ENDIF.
    ENDFORM. " DELETE_HEADER_EMPTY_RECS
    *& Form UPLOAD_MATMAS
    * to upload Material Master data
    FORM UPLOAD_MATMAS .
      LOOP AT IT_DATA.
    * Header
        UNPACK IT_DATA-MATNR TO IT_DATA-MATNR.
        BAPI_HEAD-MATERIAL = IT_DATA-MATNR.
        BAPI_HEAD-IND_SECTOR = IT_DATA-MBRSH.
        BAPI_HEAD-MATL_TYPE = IT_DATA-MTART.
        BAPI_HEAD-BASIC_VIEW = 'X'.
        BAPI_HEAD-PURCHASE_VIEW = 'X'.
        BAPI_HEAD-ACCOUNT_VIEW = 'X'.
    * Material Description
        REFRESH IT_MAKT.
        IT_MAKT-LANGU = IT_DATA-SPRAS.
        IT_MAKT-MATL_DESC = IT_DATA-MAKTX.
        APPEND IT_MAKT.
    * Client Data - Basic
        BAPI_MARA1-MATL_GROUP = IT_DATA-MATKL.
        BAPI_MARA1-BASE_UOM = IT_DATA-MEINS.
        BAPI_MARA1-UNIT_OF_WT = IT_DATA-GEWEI.
        BAPI_MARA1-DIVISION = IT_DATA-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 = IT_DATA-WERKS.
        BAPI_MARC1-PUR_GROUP = IT_DATA-EKGRP.
        BAPI_MARCX-PLANT = IT_DATA-WERKS.
        BAPI_MARCX-PUR_GROUP = 'X'.
    * Accounting
        BAPI_MBEW1-VAL_AREA = IT_DATA-WERKS.
        BAPI_MBEW1-PRICE_CTRL = IT_DATA-VPRSV.
        BAPI_MBEW1-STD_PRICE = IT_DATA-STPRS.
        BAPI_MBEW1-PRICE_UNIT = IT_DATA-PEINH.
        BAPI_MBEWX-VAL_AREA = IT_DATA-WERKS.
        BAPI_MBEWX-PRICE_CTRL = 'X'.
        BAPI_MBEWX-STD_PRICE = 'X'.
        BAPI_MBEWX-PRICE_UNIT = '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:' ,IT_DATA-MATNR.
        ELSEIF BAPI_RETURN-TYPE = 'S'.
          WRITE: 'Successfully created material' ,IT_DATA-MATNR.
        ENDIF.
      ENDLOOP.
    ENDFORM. " UPLOAD_MATMAS

  • Copy Material Master Record -- All Answers will be rewarded

    Hello All,
    I need to copy the set of materials from one plant to another plant.
    Say I need to copy Materials from plant 1123 to 1128.
    Say some 10000 materials approximately.
    one way is to create using MM01 with the reference Material. However this is not possible as different material numbers can have different Views.
    Is there a smart way to do this.
    Please let me know Marting...I will Reward all Answers
    Regards
    Marting

    try this sample program in which it will copy one material to another material it will work
    REPORT ZM_MAT_EXT_TO_PLANT
           NO STANDARD PAGE HEADING
           LINE-SIZE 255
           MESSAGE-ID ZI.
    Program     : ZM_MAT_EXT_TO_PLANT                                   *
    Author      : warun kumar todimala P                                              *
    Type        : Extend Material from one plant to another using BDC   *
    Description : The program will use BDC CALL TRANSACTION to extend   *
                   material from one plant to another plant. If error    *
                   occurs, an error session will be created with name    *
                   given on selection screen. So that it can be manually *
                   processed using SM35                                  *
    TCODE used  : MM01 - Create Material                                *
    SAP Request : D51K912730                                            *
    Date        : 13SEP2006                                             *
      C H A N G E   L O G                                                *
      Date  | Req No    | Initial  | Description
    14SEP06  D51K912772             Plant validation from T001W          *
                                    Warehouse view validation            *
    18SEP06  D51K912817             Change for xl file                   *
        Tables Declaration
    TABLES: MARA,  "General Material Data
            MARC,  "Plant Data for Material
            MVKE,  "Sales Data for Material
            MBEW,  "Material Valuation
            MARD,  "Storage Location Data for Material
            MAKT,  "Material Descriptions
            T100,  "Messages
            T130M, "Transaction control parameters: mat. master maintenance
            MLGN.  "Material Data for Each Warehouse Number
    Internal table declaration
    *--Internal table for Sales data for material
    DATA: BEGIN OF INT_MVKE OCCURS 0,
            MATNR LIKE MVKE-MATNR,
            VKORG LIKE MVKE-VKORG,
            VTWEG LIKE MVKE-VTWEG,
            VMSTA LIKE MVKE-VMSTA,
            VMSTD LIKE MVKE-VMSTD,
            DWERK LIKE MVKE-DWERK,
            KONDM LIKE MVKE-KONDM,
            PRODH LIKE MVKE-PRODH,
            MTPOS LIKE MVKE-MTPOS,
          END OF INT_MVKE.
    *--Internal table for material if input file is given
    TYPES: BEGIN OF T_MAT,
            MATNR LIKE MATERIALID-MATNR_EXT,
            SLGORT LIKE MARD-LGORT,
            TLGORT LIKE MARD-LGORT,
           END OF T_MAT.
    TYPES: BEGIN OF T_VALID_MAT,
           MATNR LIKE MATERIALID-MATNR_EXT,
          END OF  T_VALID_MAT.
    DATA: BEGIN OF IT_RMAT OCCURS 0,
            MATNR  LIKE MARA-MATNR,
            TLGORT LIKE MARD-LGORT,
            SLGORT LIKE MARD-LGORT,
          END OF IT_RMAT.
    *--Warehouse data
    DATA: BEGIN OF INT_WAREH OCCURS 0,
            MATNR LIKE MLGN-MATNR,
            LGNUM LIKE MLGN-LGNUM,
            LTKZA LIKE MLGN-LTKZA,
            LTKZE LIKE MLGN-LTKZE,
            LGBKZ LIKE MLGN-LGBKZ,
         END OF INT_WAREH.
    *--Marked for deletion
    TYPES: BEGIN OF T_MAR_DEL,
           MATNR LIKE MARA-MATNR,
           LVORM LIKE MARA-LVORM,
          END OF  T_MAR_DEL.
    *--Range for material FOR input file in
    in internal format
    RANGES: R_MATNR FOR MARA-MATNR.
    *--Internal table for Material Valuation
    DATA: BEGIN OF INT_MBEW OCCURS 0,
            MATNR LIKE MBEW-MATNR,
            VPRSV LIKE MBEW-VPRSV,
            STPRS LIKE MBEW-STPRS,
            BKLAS LIKE MBEW-BKLAS,
            ZPLD1 LIKE MBEW-ZPLD1,
            ZPLD2 LIKE MBEW-ZPLD2,
          END OF INT_MBEW.
    *--Types for inal internal table contains all the data used to extend
    *--the material(s)
    TYPES: BEGIN OF T_FINAL,
            MATNR LIKE MARA-MATNR,
            MTART LIKE MARA-MTART,
            VPSTA LIKE MARA-VPSTA,
            MBRSH LIKE MARA-MBRSH,
            MEINS LIKE MARA-MEINS,
            MATKL LIKE MARA-MATKL,
            GEWEI LIKE MARA-GEWEI,
            RAUBE LIKE MARA-RAUBE,
            SPART LIKE MARA-SPART,
            PRDHA LIKE MARA-PRDHA,
            MAGRV LIKE MARA-MAGRV,
            WERKS LIKE MARC-WERKS,
            PSTAT LIKE MARC-PSTAT,
            PLIFZ LIKE MARC-PLIFZ,
            SSQSS LIKE MARC-SSQSS,
            LADGR LIKE MARC-LADGR,
            SERNP LIKE MARC-SERNP,
            PERIV LIKE MARC-PERIV,
            STAWN LIKE MARC-STAWN,
            HERKL LIKE MARC-HERKL,
            EKGRP LIKE MARC-EKGRP,
            DISMM LIKE MARC-DISMM,
            DISPO LIKE MARC-DISPO,
            DISLS LIKE MARC-DISLS,
            LGPRO LIKE MARC-LGPRO,
            FHORI LIKE MARC-FHORI,
            DZEIT LIKE MARC-DZEIT,
            BWSCL LIKE MARC-BWSCL,
            AWSLS LIKE MARC-AWSLS,
            LGFSB LIKE MARC-LGFSB,
            MAKTX LIKE MAKT-MAKTX,
           TLGORT LIKE MARD-LGORT,
           SLGORT LIKE MARD-LGORT,
            VKORG LIKE MVKE-VKORG,
            VTWEG LIKE MVKE-VTWEG,
            VMSTA LIKE MVKE-VMSTA,
            VMSTD LIKE MVKE-VMSTD,
            DWERK LIKE MVKE-DWERK,
            KONDM LIKE MVKE-KONDM,
            PRODH LIKE MVKE-PRODH,
            MTPOS LIKE MVKE-MTPOS,
            VPRSV LIKE MBEW-VPRSV,
            STPRS LIKE MBEW-STPRS,
            BKLAS LIKE MBEW-BKLAS,
            ZPLD1 LIKE MBEW-ZPLD1,
            ZPLD2 LIKE MBEW-ZPLD2,
            LGNUM LIKE MLGN-LGNUM,
            LTKZA LIKE MLGN-LTKZA,
            LTKZE LIKE MLGN-LTKZE,
            LGBKZ LIKE MLGN-LGBKZ,
        END OF T_FINAL.
    TYPES: BEGIN OF T_LOG,
            MATNR LIKE MATERIALID-MATNR_EXT,
            MTART LIKE MARA-MTART,
            WERKS LIKE MARC-WERKS,
            MSG(480),
            MSGTYP TYPE C,
           END OF T_LOG.
    TYPES: BEGIN OF T_INVALID,
            MATNR LIKE MATERIALID-MATNR_EXT,
            WERKS LIKE MARC-WERKS,
            MSG(100),
           END OF T_INVALID.
    *--Internal to for mateial descriptions
    *DATA: BEGIN OF INT_MAT_DES OCCURS 0,
           MATNR LIKE MAKT-MATNR,
           MAKTX LIKE MAKT-MAKTX,
         END OF INT_MAT_DES.
    DATA: BEGIN OF IT_FINAL1 OCCURS 0,
            MATNR LIKE MATERIALID-MATNR_EXT,
            MTART LIKE MARA-MTART,
            MBRSH LIKE MARA-MBRSH,
            WERKS LIKE MARC-WERKS,
            PSTAT LIKE MARC-PSTAT,
            LGPRO LIKE MARC-LGPRO,
            LGFSB LIKE MARC-LGFSB,
           TLGORT LIKE MARD-LGORT,
           SLGORT LIKE MARD-LGORT,
          END OF IT_FINAL1.
    *--Internal table for Storage Location Data
    DATA : BEGIN OF INT_MARD OCCURS 0,
            MATNR LIKE MARD-MATNR,
            WERKS LIKE MARD-WERKS,
            LGORT LIKE MARD-LGORT,
           END OF INT_MARD.
    *--For Views
    TYPES: BEGIN OF T_XBILDTAB.
            INCLUDE STRUCTURE MBILDTAB.
    TYPES: END   OF T_XBILDTAB.
    *--Internal table for VIEWS
    DATA: IT_XBILDTAB TYPE STANDARD TABLE OF  T_XBILDTAB WITH HEADER LINE.
    *--Final internal table contains all the data used to extend the
    material(s)
    DATA: IT_FINAL  TYPE STANDARD TABLE OF T_FINAL WITH HEADER LINE,
          IT_TPLANT TYPE STANDARD TABLE OF T_FINAL WITH HEADER LINE,
        int_fplant TYPE STANDARD TABLE OF t_final WITH HEADER LINE,
          IT_TOTAL  TYPE STANDARD TABLE OF T_FINAL WITH HEADER LINE,
          WA_FINAL   TYPE T_FINAL,
          WA_TPLANT  TYPE T_FINAL,
          INT_TEST   TYPE STANDARD TABLE OF T_FINAL WITH HEADER LINE,
          WA_T130M   LIKE T130M,
    *--table for bdcdata to store the bdc data
           IT_BDCDATA TYPE STANDARD TABLE OF BDCDATA WITH HEADER LINE,
    *--table for messages come from the 'CALL TRANSACTION'
          IT_MESSTAB  LIKE BDCMSGCOLL OCCURS 0   WITH HEADER LINE,
          IT_SREP     TYPE STANDARD TABLE OF T_LOG WITH HEADER LINE,
          IT_EREP     TYPE STANDARD TABLE OF T_LOG WITH HEADER LINE,
          IT_AVL      TYPE STANDARD TABLE OF T_LOG WITH HEADER LINE,
          IT_ERR      TYPE STANDARD TABLE OF T_LOG WITH HEADER LINE,
          IT_DUPREC   TYPE STANDARD TABLE OF T_MAT WITH HEADER LINE,
          IT_MAT      TYPE STANDARD TABLE OF T_MAT WITH HEADER LINE,
          IT_MAT1     TYPE STANDARD TABLE OF T_MAT WITH HEADER LINE,
          IT_DELREC   TYPE STANDARD TABLE OF T_MAT WITH HEADER LINE,
          IT_MAR_DEL  TYPE STANDARD TABLE OF T_MAR_DEL WITH HEADER LINE,
          IT_DELREC35 TYPE STANDARD TABLE OF T_MAT WITH HEADER LINE,
          IT_VALID_REC TYPE STANDARD TABLE OF T_VALID_MAT WITH HEADER LINE,
          IT_IN_VALID TYPE STANDARD TABLE OF T_VALID_MAT WITH HEADER LINE,
          IT_INVALID  TYPE STANDARD TABLE OF T_INVALID WITH HEADER LINE,
          IT_INVALID1 TYPE STANDARD TABLE OF T_INVALID WITH HEADER LINE,
    *--Standard views
           IT_T133A TYPE STANDARD TABLE OF T133A WITH HEADER LINE,
           IT_T134  TYPE STANDARD TABLE OF  T_XBILDTAB WITH HEADER LINE.
         Global variables declaration
    DATA:
       GV_TRANS_CODE TYPE SY-TCODE VALUE 'MM01',"Tcode
       GV_MTART LIKE MARA-MTART,                "Material type
       GV_MATNR LIKE MATERIALID-MATNR_EXT,      "40 char material
       HOLDDATE LIKE SY-DATUM,                  "Holdate for session
       GV_SES_OPEN,                             "Session open check
       GV_LAST LIKE MBILDTAB-GUIFU,             "View code
       GV_VIEW_CODE LIKE MBILDTAB-GUIFU,        "Function code
       GV_PURCH_VIEW TYPE I,                    "Purch view
       GV_FIRST_VIEW(2) TYPE N,                 "First view
       GV_OKCODE TYPE SY-UCOMM,                 "Ok code
       GV_MSG1(150),                            "Message
       GV_CNTR TYPE I VALUE '1',                "Counter
       GV_VIEW_CNT LIKE SY-TABIX,               "View count
       GV_NXT_VIEW LIKE MBILDTAB-GUIFU,         "Function code
       GV_ERCNT TYPE I,                         "Error records  count
       GV_SCNT  TYPE I,                         "Success records count
       GV_VALIDREC  TYPE I,                     "Valid record count
       GV_DUPREC  TYPE I,                       "Duplicate record count
       GV_AVL   TYPE I,                         "Available records count
       GV_MSG(120),                             "Message
       GV_INREC   TYPE I,                       "Input records count
       GV_MAR_DEL TYPE I,                       "Marked for deletion
       GV_FILE_STR TYPE STRING,                 "Hold file name except 'txt'
       GV_LAST_4_CHARS TYPE STRING,             "To hold '.txt' from inpfile
       GV_TCNT TYPE I,                          "Total record count
       GV_INVALID_REC TYPE I,                   "Invalide record count
       GV_FILE_CRT_Y_OR_NO  TYPE C.             "file created or not
    CONSTANTS
    CONSTANTS:
          TCODE_MM01 LIKE TSTC-TCODE VALUE 'MM01',
          C_UPDATE TYPE C VALUE 'A'.
    S E L E C T - O P T I O N S
    SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    SELECTION-SCREEN: BEGIN OF LINE.
    SELECTION-SCREEN: COMMENT 1(25) TEXT-009.
    SELECTION-SCREEN: POSITION 33.
    PARAMETER  P_WH  AS CHECKBOX DEFAULT 'X'.
    SELECTION-SCREEN: END OF LINE.
    SELECT-OPTIONS   : S_MATNR  FOR MARA-MATNR.
    PARAMETERS       : P_FWERKS LIKE MARC-WERKS OBLIGATORY,
                       P_TWERKS LIKE MARC-WERKS OBLIGATORY.
    SELECTION-SCREEN : END OF BLOCK B1.
    SELECTION-SCREEN : BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
    SELECTION-SCREEN: BEGIN OF LINE.
    SELECTION-SCREEN: COMMENT 1(25) TEXT-004.
    SELECTION-SCREEN: POSITION 32.
    *--Input file
    PARAMETERS: P_IFILE LIKE RLGRAP-FILENAME. "input file
    SELECTION-SCREEN: END OF LINE.
    SELECTION-SCREEN: BEGIN OF LINE.
    SELECTION-SCREEN: COMMENT 1(25) TEXT-005.
    SELECTION-SCREEN: POSITION 32.
    *--Unix output file
    PARAMETERS: P_OFILE LIKE RLGRAP-FILENAME LOWER CASE DEFAULT
                   './sap_out/matextplnt'. "Output file in UNIX
    SELECTION-SCREEN: END OF LINE.
    SELECTION-SCREEN: BEGIN OF LINE.
    SELECTION-SCREEN: COMMENT 1(25) TEXT-012.
    SELECTION-SCREEN: POSITION 32.
    *--PC file ( used to create the files from internal tables)
    PARAMETERS: P_PCFILE LIKE RLGRAP-FILENAME LOWER CASE OBLIGATORY
                DEFAULT 'C:\'.
    SELECTION-SCREEN: END OF LINE.
    SELECTION-SCREEN : END OF BLOCK B2.
    SELECTION-SCREEN : BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-003.
    *--Session Name
    PARAMETERS       : P_GROUP LIKE APQI-GROUPID DEFAULT 'MAT_Extension'.
    *--Mode (like All Screen - A)
    PARAMETERS P_MODE LIKE CTU_PARAMS-DISMODE DEFAULT 'N'.
    SELECTION-SCREEN: END OF BLOCK B3.
    *-            A T   S E L E C T I O N   S C R E E N
    AT SELECTION-SCREEN.
      IF ( P_IFILE = ' ' ) AND ( S_MATNR[] IS INITIAL ).
        MESSAGE E000(ZI) WITH 'Please Enter the Material or Input file'.
      ENDIF.
    *--download the data from pc file
      IF P_IFILE NE ' '.
        PERFORM VALIDATE_IN_FILE.
        PERFORM GET_DATA_FRM_FILE.
      ENDIF.
    Validate selection screen entries
      PERFORM VALIDATE_SEL_SCREEN_ENTRIES.
    *-            A T   S E L E C T I O N   S C R E E N --- Value Request
    *--F4 help for input flie
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_IFILE.
      PERFORM VALUE_REQUEST_FOR_PC_FILE USING P_IFILE.
    *--F4 help for pc file
    *AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_PCFILE.
    PERFORM VALUE_REQUEST_FOR_PC_FILE USING P_PCFILE.
    *--F4 help for Unix file
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_OFILE.
      PERFORM VALUE_REQ_FOR_UNIX_FILE USING P_OFILE.
                   T  O  P     O F      P A G E
    TOP-OF-PAGE.
      PERFORM TOP_OF_PAGE.
    S E L E C T - O P T I O N S
    START-OF-SELECTION.
    *--Fecth the data from the Data Base tables
      PERFORM GET_DATA.
    *--Process the above data to create the final internal table
      PERFORM PROCESS_DATA.
    *--Extend the data to plant
      PERFORM EXTEND_DATA_2_PLANT.
    end of selection
    END-OF-SELECTION.
      PERFORM MAT_CONV_FOR_ALL_INT_TABLES.
    *--Success
      DESCRIBE TABLE IT_SREP   LINES  GV_SCNT.
    *--Error
      DESCRIBE TABLE IT_EREP   LINES  GV_ERCNT.
    *--Already existing
      DESCRIBE TABLE IT_AVL    LINES  GV_AVL.
    *--Input
      DESCRIBE TABLE IT_MAT     LINES  GV_INREC.
    *--Valid
      DESCRIBE TABLE IT_FINAL1  LINES  GV_VALIDREC.
    *--Duplicate
      DESCRIBE TABLE IT_DUPREC  LINES  GV_DUPREC.
    *--Marked for deletion
      DESCRIBE TABLE IT_DELREC LINES  GV_MAR_DEL.
    *--Invalid
      DESCRIBE TABLE IT_INVALID LINES  GV_INVALID_REC.
      GV_TCNT =
      GV_ERCNT + GV_SCNT + GV_AVL + GV_INVALID_REC + GV_DUPREC +
      GV_MAR_DEL + GV_VALIDREC + GV_INREC.
      IF  GV_TCNT NE 0.
    *--create output PC files for each internal table
        PERFORM PC_FILES_CREATION.
    *--Create Unix file all internal tables
        PERFORM OUT_UNIX_FILE. "create unix file for output.
    *--Create the report
        PERFORM REPORT_DIS.
    *--Clear the contents
        CLEAR: IT_SREP,
               IT_EREP,
               IT_AVL,
               IT_MAT,
               IT_FINAL1,
               IT_DUPREC,
               IT_DELREC,
               IT_INVALID.
        REFRESH:
               IT_SREP,
               IT_EREP,
               IT_AVL,
               IT_MAT,
               IT_FINAL1,
               IT_DUPREC,
               IT_DELREC,
               IT_INVALID.
      ELSE.
        FORMAT COLOR 6 INTENSIFIED ON.
        WRITE:/ 'No Data found for the Selection Criteria'(007).
        FORMAT RESET.
      ENDIF.
    *&      Form  get_data
    *--Fetch the data from required data base tables
    FORM GET_DATA .
      DATA: LV_TABIX LIKE SY-TABIX.
    **--Material type is in BAPI structures filling.
      IF P_IFILE NE ' '.
        PERFORM CONVERT_MAT_FRM_FILE.
      ENDIF.
    *--Ranges for the plants
      RANGES:R_WERKS FOR MARC-WERKS.
      R_WERKS-SIGN = 'I'.
      R_WERKS-OPTION = 'EQ'.
      R_WERKS-LOW = P_FWERKS.
      APPEND R_WERKS.
      R_WERKS-SIGN = 'I'.
      R_WERKS-OPTION = 'EQ'.
      R_WERKS-LOW = P_TWERKS.
      APPEND R_WERKS.
      CLEAR R_WERKS.
    *--Fetch the data for the given selection from the DB table MARA & MARC
    (General Material Data)
      IF P_IFILE NE ' '.
        SELECT R~MATNR "R = MARA
               R~VPSTA
               R~MTART
               R~MATKL
               R~MBRSH
               R~MEINS
               R~GEWEI
               R~RAUBE
               R~SPART
               R~PRDHA
               R~MAGRV
               C~MATNR "C = MARC
               C~WERKS
               C~PSTAT
               C~PLIFZ
               C~SSQSS
               C~LADGR
               C~SERNP
               C~PERIV
               C~STAWN
               C~HERKL
               C~EKGRP
               C~DISMM
               C~DISPO
               C~DISLS
               C~LGPRO
               C~FHORI
               C~DZEIT
               C~BWSCL
               C~AWSLS
               C~LGFSB
          INTO CORRESPONDING FIELDS OF TABLE IT_TOTAL
          FROM  ( MARA AS R
                   INNER JOIN MARC AS C ON CMATNR = RMATNR )
          WHERE R~MATNR IN R_MATNR  AND
             R~MTART IN S_MTART  AND
                C~WERKS IN R_WERKS .
        LOOP AT IT_TOTAL.
          LV_TABIX = SY-TABIX.
          READ TABLE IT_RMAT WITH KEY MATNR = IT_TOTAL-MATNR.
          IF SY-SUBRC =  0.
            IT_TOTAL-TLGORT = IT_RMAT-TLGORT.
            IT_TOTAL-SLGORT = IT_RMAT-SLGORT.
            MODIFY IT_TOTAL INDEX LV_TABIX.
          ENDIF.
        ENDLOOP.
      ELSE.
        SELECT R~MATNR "R = MARA
               R~VPSTA
               R~MTART
               R~MATKL
               R~MBRSH
               R~MEINS
               R~GEWEI
               R~RAUBE
               R~SPART
               R~PRDHA
               R~MAGRV
               C~MATNR "C = MARC
               C~WERKS
               C~PSTAT
               C~PLIFZ
               C~SSQSS
               C~LADGR
               C~SERNP
               C~PERIV
               C~STAWN
               C~HERKL
               C~EKGRP
               C~DISMM
               C~DISPO
               C~DISLS
               C~LGPRO
               C~FHORI
               C~DZEIT
               C~BWSCL
               C~AWSLS
               C~LGFSB
          INTO CORRESPONDING FIELDS OF TABLE IT_TOTAL
          FROM  ( MARA AS R
                   INNER JOIN MARC AS C ON CMATNR = RMATNR )
          WHERE R~MATNR IN S_MATNR  AND
             R~MTART IN S_MTART  AND
                C~WERKS IN R_WERKS .
      ENDIF.  "  if P_IFILE ne ' '.
      IF NOT IT_TOTAL[] IS INITIAL.
        SORT IT_TOTAL BY WERKS.
        IT_FINAL[]  = IT_TOTAL[].
        IT_TPLANT[] = IT_TOTAL[].
        SORT IT_FINAL  BY WERKS.
        SORT IT_TPLANT BY WERKS.
    *Logic 1
    *--Delete all entries having the plant value equal to 'to plant' value
    *--So, IT_FINAL have only from plant data. But in which some data
    *--already in 'to plant'
        DELETE IT_FINAL WHERE WERKS = P_TWERKS.
    *Logic 2
    *--Delete all entries having the plant value equal to 'from plant' value
        DELETE IT_TPLANT WHERE WERKS = P_FWERKS.
    IF NOT IT_FINAL[] IS INITIAL.
        SORT IT_FINAL BY MATNR WERKS.
        SORT IT_TPLANT BY MATNR WERKS.
    *Logic 3
    *--Delete all the material from the 'IT_FINAL', which is already
    extended to 'to plnat'.
    In Logic 1 and Logic 2, just deleted the materials having the plant
    value equal same. Here 'IT_FINAL' contains materials of 'from plant'
    only,because 'to plant' materials have been deleted in the  'Logic1'.
    But it contains the materials already extended to 'to plant', So we
    Need to delete those. And it is done in the below Logic. From now
    'IT_FINAL table contains materials that are to be extended.
    (Already extended materials have been deleted)
        LOOP AT IT_TPLANT.
          READ TABLE IT_FINAL
               WITH KEY MATNR = IT_TPLANT-MATNR
                        WERKS = P_FWERKS
                        BINARY SEARCH.
          LV_TABIX = SY-TABIX.
          IF SY-SUBRC EQ 0.
    *--continue the process. This materil to be extend for other views
            IF IT_FINAL-PSTAT = IT_TPLANT-PSTAT.
              IT_AVL-MATNR   = IT_TPLANT-MATNR.
              IT_AVL-WERKS   = P_TWERKS.
              IT_AVL-MTART   = IT_TPLANT-MTART.
              IT_AVL-MSG     = 'Material already in plant'.
              IT_AVL-MSGTYP = 'E'.
              APPEND IT_AVL.
              CLEAR IT_AVL.
              DELETE IT_FINAL INDEX LV_TABIX.
              CLEAR IT_FINAL.
    *--If the material already exist in the target plant, check for the
    *--warehouse view. If only warehoues view does not exist and checked
    warehouse not required, then consider that the record is exist
    in target plant
            ELSEIF IT_FINAL-PSTAT CA 'S' AND IT_TPLANT-PSTAT NA 'S'.
    If warehouse view does not require, then no need to copy again
              IF P_WH = 'X'.
                IT_AVL-MATNR   = IT_TPLANT-MATNR.
                IT_AVL-WERKS   = P_TWERKS.
                IT_AVL-MTART   = IT_TPLANT-MTART.
                IT_AVL-MSG     = 'Material already in plant'.
                IT_AVL-MSGTYP = 'E'.
                APPEND IT_AVL.
                CLEAR IT_AVL.
                DELETE IT_FINAL INDEX LV_TABIX.
                CLEAR IT_FINAL.
              ENDIF.
            ENDIF.
          ENDIF.
        ENDLOOP.
      ENDIF.
    *--Logic 4 ( Get the data from MARD, MVKE, MBEW and MAKT)
      IF NOT IT_FINAL[] IS INITIAL.
    *--Get the data from DB tabel MVKE (Sales Data for Material)
    for all the materials in 'IT_FINAL'.
        SELECT
             MATNR
             VKORG
             VTWEG
             VMSTA
             VMSTD
             DWERK
             KONDM
             PRODH
             MTPOS
             FROM  MVKE
             INTO  TABLE INT_MVKE
             FOR   ALL ENTRIES IN IT_FINAL
             WHERE MATNR = IT_FINAL-MATNR.
    *--Get the data from DB table MBEW (Material Valuation)
    for all the materials in 'IT_FINAL'.
        SELECT
            MATNR
            VPRSV
            STPRS
            BKLAS
            ZPLD1
            ZPLD2
            FROM MBEW
            INTO TABLE INT_MBEW
            FOR ALL ENTRIES IN IT_FINAL
            WHERE MATNR = IT_FINAL-MATNR AND
                  BWKEY = IT_FINAL-WERKS.
    Start of change by Hema on 09/21/06
    Since basic view is not required to copy, no need description also
    *--Get the data from DB table MAKT (Material Descriptions)
    for all the materials in 'IT_FINAL'.
       SELECT MATNR
              MAKTX
              FROM MAKT
              INTO CORRESPONDING FIELDS OF TABLE INT_MAT_DES
              FOR ALL ENTRIES IN IT_FINAL
              WHERE MATNR =  IT_FINAL-MATNR AND
                    SPRAS =  SY-LANGU.
    End of change by Hema on 09/21/06
    *--Get the warehouse data.
        SELECT MATNR
               LTKZA
               LTKZE
               LGBKZ
               INTO CORRESPONDING FIELDS OF TABLE INT_WAREH
               FROM MLGN
               FOR ALL ENTRIES IN IT_FINAL
               WHERE MATNR = IT_FINAL-MATNR.
        SELECT  SINGLE * FROM T130M
                INTO WA_T130M
                WHERE TCODE = GV_TRANS_CODE.
    *--Sort the internal table by material
        SORT INT_MARD     BY MATNR WERKS.
        SORT INT_MVKE     BY MATNR.
        SORT INT_MBEW     BY MATNR.
       SORT INT_MAT_DES  BY MATNR.
        SORT INT_WAREH     BY MATNR.
      ENDIF.
    ENDFORM.                    " get_data
    *&      Form  process_data
    *--Fill the final internal with data from all the internal tables
    FORM PROCESS_DATA .
      DATA: LV_LINES TYPE I.
    *--Logic 5: Fill the 'IT_FINAL' table from the 'int_mard', 'int_mvke'
              'int_mat_des' and int_mbew' as follows.
      LOOP AT IT_FINAL.
    *--Copy Target storage locaction to Prod.Stor.Loc and stor.Loc.for EP
        IT_FINAL-LGPRO = IT_FINAL-TLGORT.
        IT_FINAL-LGFSB = IT_FINAL-TLGORT.
        READ TABLE INT_MVKE WITH KEY MATNR = IT_FINAL-MATNR
                                     BINARY SEARCH.
        IF SY-SUBRC EQ 0.
          IT_FINAL-VKORG = INT_MVKE-VKORG.
          IT_FINAL-VTWEG = INT_MVKE-VTWEG.
          IT_FINAL-VMSTA = INT_MVKE-VMSTA.
          IT_FINAL-VMSTD = INT_MVKE-VMSTD.
          IT_FINAL-DWERK = INT_MVKE-DWERK.
          IT_FINAL-KONDM = INT_MVKE-KONDM.
          IT_FINAL-PRODH = INT_MVKE-PRODH.
          IT_FINAL-MTPOS = INT_MVKE-MTPOS.
        ENDIF.
       READ TABLE INT_MAT_DES WITH KEY MATNR = IT_FINAL-MATNR
                                    BINARY SEARCH.
       IF SY-SUBRC EQ 0.
         IT_FINAL-MAKTX = INT_MAT_DES-MAKTX.
       ENDIF.
        READ TABLE INT_MBEW WITH KEY MATNR = IT_FINAL-MATNR
                                     BINARY SEARCH.
        IF SY-SUBRC EQ 0.
          IT_FINAL-VPRSV = INT_MBEW-VPRSV.
          IT_FINAL-STPRS = INT_MBEW-STPRS.
          IT_FINAL-BKLAS = INT_MBEW-BKLAS.
          IT_FINAL-ZPLD1 = INT_MBEW-ZPLD1.
          IT_FINAL-ZPLD2 = INT_MBEW-ZPLD2.
        ENDIF.
        READ TABLE INT_WAREH WITH KEY MATNR = IT_FINAL-MATNR
                                BINARY SEARCH.
        IF SY-SUBRC EQ 0.
          IT_FINAL-LGNUM = INT_WAREH-LGNUM.
          IT_FINAL-LTKZA = INT_WAREH-LTKZA.
          IT_FINAL-LTKZE = INT_WAREH-LTKZE.
          IT_FINAL-LGBKZ = INT_WAREH-LGBKZ.
        ENDIF.
        MODIFY IT_FINAL
               TRANSPORTING
                            VKORG
                            VTWEG
                            VMSTA
                            VMSTD
                            LGPRO
                            LGFSB
                            DWERK
                            KONDM
                            PRODH
                            MTPOS
                            MAKTX
                            VPRSV
                            STPRS
                            BKLAS
                            ZPLD1
                            ZPLD2
                            LGNUM
                            LTKZA
                            LTKZE
                            LGBKZ.
      ENDLOOP.
    ENDFORM.                    " process_data
    *&      Form  value_request_for_pc_file
    *--F4 help for the file names.
    FORM VALUE_REQUEST_FOR_PC_FILE  USING  P_FILE.
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          PROGRAM_NAME  = SY-CPROG
          DYNPRO_NUMBER = SY-DYNNR
          FIELD_NAME    = ' '
        IMPORTING
          FILE_NAME     = P_FILE.
    ENDFORM.                    " value_request_for_pc_file
    *&      Form  extend_data_2_plant
    *--Use the final internal table to extend the material from one plant 2
    *--another using the following logic which involved in 'four performs'
    FORM EXTEND_DATA_2_PLANT .
      DATA: BEGIN OF INT_VIEWS OCCURS 0.
              INCLUDE STRUCTURE MBILDTAB.
      DATA  END OF INT_VIEWS.
      IF NOT IT_FINAL[] IS INITIAL.
        LOOP AT IT_FINAL.
          GV_MTART = IT_FINAL-MTART.
    *--Get the 32 char Lenth Material number
         PERFORM MATERIAL_CON USING IT_FINAL-MATNR.
          CALL FUNCTION 'CONVERSION_EXIT_MATN2_OUTPUT'
            EXPORTING
              INPUT  = IT_FINAL-MATNR
            IMPORTING
              OUTPUT = GV_MATNR.
    *--Get the views for the current material
          PERFORM GET_THE_VIEWS_4_MAT.
    *--Fill bdctable for all view available in 'copy from material'
          PERFORM CREATE_DATA_FOR_VIEWS.
    *--Use the above structures and call the 'MM01' to extend the material
          PERFORM EXTEND_MAT_2_PLANT.
          CLEAR: GV_FIRST_VIEW, GV_NXT_VIEW,  GV_MATNR.
        ENDLOOP.
    *--close the session if open
        IF GV_SES_OPEN EQ 'X'.
          PERFORM CLOSE_GRP.
          SKIP 1.
          WRITE:/5 'Session Created', 40 P_GROUP COLOR 4.
        ENDIF.
      ELSE.
        SKIP 2.
        WRITE:/5 TEXT-010 COLOR 4.
       'No Data exists for the given selection'.
      ENDIF.
      IF NOT IT_EREP[] IS INITIAL.
        LOOP AT IT_EREP.
          CALL FUNCTION 'CONVERSION_EXIT_MATN2_OUTPUT'
            EXPORTING
              INPUT  = IT_EREP-MATNR
            IMPORTING
              OUTPUT = IT_EREP-MATNR.
          IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ELSE.
            MODIFY IT_EREP.
          ENDIF.
        ENDLOOP.
      ENDIF.
    ENDFORM.                    " extend_data_2_plant
    *&      Form  get_the_views_4_mat
    *--Get the views for current material
    FORM GET_THE_VIEWS_4_MAT .
      DATA: LV_BILDSEQUENZ   TYPE T133A-BILDS,
            LV_PSTAT LIKE T134-PSTAT.
      CLEAR: T130M,
             LV_BILDSEQUENZ,
             IT_XBILDTAB.
      REFRESH IT_XBILDTAB.
    *--Get the Build sequece for particular Material type
      CALL FUNCTION 'BILDSEQUENZ_IDENTIFY'
        EXPORTING
         BRANCHE                = IT_FINAL-MBRSH
         MATERIALART            = IT_FINAL-MTART
         TCODE_REF              = WA_T130M-TRREF
         KZRFB                  = ' '
       IMPORTING
         BILDSEQUENZ            = LV_BILDSEQUENZ
         KZ_BILDS_CHANGED       =
       EXCEPTIONS
         WRONG_CALL             = 1
         NOT_FOUND              = 2
         OTHERS                 = 3
    *--Get the actual number views for the current material will stored
    *--in the internal table 'IT_XBILDTAB'.
      IF SY-SUBRC = 0.
        CALL FUNCTION 'SELECTION_VIEWS_FIND'
          EXPORTING
            BILDSEQUENZ     = LV_BILDSEQUENZ
          PFLEGESTATUS    = IT_FINAL-VPSTA
            PFLEGESTATUS    = IT_FINAL-PSTAT
          TABLES
            BILDTAB         = IT_XBILDTAB
          EXCEPTIONS
            CALL_WRONG      = 1
            EMPTY_SELECTION = 2
            OTHERS          = 3.
      ENDIF.
    *--Build actual table for view sequence
      SELECT SINGLE PSTAT FROM T134
                    INTO LV_PSTAT
                    WHERE MTART = GV_MTART.
      CALL FUNCTION 'SELECTION_VIEWS_FIND'
        EXPORTING
          BILDSEQUENZ     = '01'
          PFLEGESTATUS    = LV_PSTAT
        TABLES
          BILDTAB         = IT_T134
        EXCEPTIONS
          CALL_WRONG      = 1
          EMPTY_SELECTION = 2
          OTHERS          = 3.
      IF NOT IT_XBILDTAB[] IS INITIAL.
    *--Delete the Basic(SP01),
    *--Classification(SP02)
    *--Sales: Sales Organization Data(SP03)
    *--Sales: General/Plant Data(SP04)
    *--Sales Text(SP05)
    *--Production Resources and Tools(SP12) which are not required
        LOOP AT IT_XBILDTAB.
          CASE IT_XBILDTAB-GUIFU.
            WHEN 'SP01'.
              DELETE IT_XBILDTAB." WITH KEY GUIFU = 'SP01'.
            WHEN 'SP02'.
              DELETE IT_XBILDTAB." WITH KEY GUIFU = 'SP02'.
            WHEN 'SP03'.
              DELETE IT_XBILDTAB." WITH KEY GUIFU = 'SP03'.
            WHEN 'SP04'.
              DELETE IT_XBILDTAB." WITH KEY GUIFU = 'SP04'.
            WHEN 'SP05'.
              DELETE IT_XBILDTAB." WITH KEY GUIFU = 'SP05'.
            WHEN 'SP12'.
              DELETE IT_XBILDTAB." WITH KEY GUIFU = 'SP12'.
            WHEN 'SP14'.
    *--If 'do not copy warehouse' is ticked, delete the view from table.
    *--problem is, if that view is last view then Save problem will
    *--come in the BDC.
              IF P_WH EQ 'X'.
                DELETE IT_XBILDTAB.
              ENDIF.
          ENDCASE.
        ENDLOOP.
      ENDIF.
    *--Get the first view of the material to select that view from Views
    *-- List of the MM01
      LOOP AT IT_XBILDTAB.
        READ TABLE IT_T134 WITH KEY GUIFU = IT_XBILDTAB-GUIFU.
        IF SY-SUBRC EQ 0.
          GV_FIRST_VIEW = SY-TABIX.
          GV_NXT_VIEW   = IT_XBILDTAB-GUIFU.
          EXIT.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    " get_the_views_4_mat
    *&      Form  CREATE_DATA_FOR_VIEWS
          text
    -->  p1        text
    <--  p2        text
    FORM CREATE_DATA_FOR_VIEWS .
      DATA: LV_LAST_VIEW_NO TYPE I.
      DESCRIBE TABLE IT_XBILDTAB LINES LV_LAST_VIEW_NO.
      LOOP AT IT_XBILDTAB.
        IF LV_LAST_VIEW_NO EQ SY-TABIX.
          MOVE IT_XBILDTAB-GUIFU TO GV_LAST.
        ENDIF.
      ENDLOOP.
    *--Hit the Basic view in the 'View selection Pop up', i.e very beginning
    *--in Tcode: MM01. So that, only views which already in (Copy from)
    *--Material can extend to the Target Plant. Int.,table IT_XBILDTAB
    *--contains these views. Here flexibilty is that, not all views are
    *--extended, whether the 'copy from material' contains or not.
    *--i.e Dynamic selection of views.
    *--So in order to ease the Dynamic selection (of views), first
    *--Hit the Basic view in the 'View selection Pop up'.
      PERFORM FILL_BASIC_VIEW.
      PERFORM FILL_ORG_DATA USING GV_VIEW_CODE.
      LOOP AT IT_XBILDTAB.
        MOVE IT_XBILDTAB-GUIFU TO GV_VIEW_CODE.
        CASE IT_XBILDTAB-GUIFU.
         --Purchasing view
          WHEN 'SP06'.
            PERFORM FILL_PURCH_VIEW USING GV_VIEW_CODE.
         --Purchase Order Text View
          WHEN 'SP07'.
            PERFORM FILL_PURCH_ORD_TEXT USING GV_VIEW_CODE.
         --MRP1 View
          WHEN 'SP08'.
            PERFORM FILL_MRP1_VIEW USING GV_VIEW_CODE.
         --MRP2 View
          WHEN 'SP09'.
            PERFORM FILL_MRP2_VIEW USING GV_VIEW_CODE.
         --Forecast View
          WHEN 'SP10'.
            PERFORM FILL_FORECAST_VIEW USING GV_VIEW_CODE.
          WHEN 'SP11'.
            IF  GV_FLG NE 'Y'.
            PERFORM FILL_WORKSCHED_VIEW USING GV_VIEW_CODE.
            ENDIF.
         --General Plant Data / Storage View
          WHEN 'SP13'.
            PERFORM FILL_PLANT_STRGE_VIEW USING GV_VIEW_CODE.
         --Warehouse Management View
          WHEN 'SP14'.
            IF P_WH <> 'X'.
       -- If the 'do not warehouse' check box unchecked on sele screen
              PERFORM FILL_WAREHOUSE_VIEW USING GV_VIEW_CODE.
            ENDIF.
         --Quality Management View
          WHEN 'SP15'.
            PERFORM FILL_QUALITY_VIEW USING GV_VIEW_CODE.
         -- Accounting View
          WHEN 'SP16'.
            PERFORM FILL_ACCOUNTING_VIEW USING GV_VIEW_CODE.
         --Costing View
          WHEN 'SP17'.
            PERFORM FILL_COSTING_VIEW USING GV_VIEW_CODE.
         --Plant/Storage Location Stock View
          WHEN 'SP18'.
            PERFORM FILL_PLANT_ST_LOC_STK_VIEW USING GV_VIEW_CODE.
        ENDCASE.
        CLEAR GV_OKCODE.
      ENDLOOP.
    ENDFORM.                    " CREATE_DATA_FOR_VIEWS
    *&      Form  fill_basic_view
          text
    -->  p1        text
    <--  p2        text
    FORM FILL_BASIC_VIEW .
      DATA FIELD_STR(40).
      PERFORM BDC_DYNPRO      USING 'SAPLMGMM' '0060'.
      PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                    'RMMG1-MATNR'.
      PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                    '/00'.
      PERFORM BDC_FIELD       USING 'RMMG1-MATNR'
                                    GV_MATNR."nt_final-matnr.
      PERFORM BDC_FIELD       USING 'RMMG1_REF-MATNR'
                                     GV_MATNR."IT_FINAL-matnr.
      PERFORM BDC_DYNPRO      USING 'SAPLMGMM' '0070'.
      PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                    'MSICHTAUSW-DYTXT(01)'.
      PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                    '=ENTR'.
      CONCATENATE 'MSICHTAUSW-KZSEL(' GV_FIRST_VIEW ')' INTO FIELD_STR.
      PERFORM BDC_FIELD       USING FIELD_STR 'X'.
    ENDFORM.                    " fill_basic_view
    *&      Form  fill_purch_view
    Purchasing view
    FORM FILL_ORG_DATA USING GV_VIEW_CODE.
      PERFORM BDC_DYNPRO      USING 'SAPLMGMM' '0080'.
      PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                    'RMMG1_REF-WERKS'.
      PERFORM BDC_FIELD       USING 'RMMG1-WERKS'
                                     P_TWERKS.
      PERFORM BDC_FIELD       USING 'RMMG1_REF-WERKS'
                                      P_FWERKS.
      IF GV_NXT_VIEW EQ 'SP08'.
        PERFORM BDC_FIELD       USING 'RMMG1-LGORT'
                                      IT_FINAL-TLGORT.
        PERFORM BDC_FIELD       USING 'RMMG1_REF-LGORT'
                                      IT_FINAL-SLGORT.
      ENDIF.
    ENDFORM.                    " fill_org_data
    *&      Form  fill_purch_ord_text
    Purchase order text
    FORM FILL_PURCH_ORD_TEXT USING GV_VIEW_CODE.
      CONCATENATE '=' GV_VIEW_CODE INTO GV_OKCODE.
      PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                    '=SP07'.
      PERFORM BDC_DYNPRO      USING 'SAPLMGMM' '3050'.
      IF GV_VIEW_CODE EQ GV_LAST.
        PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                      '=BU'.
      ENDIF.
    ENDFORM.                    " fill_purch_ord_text
    *&      Form  fill_MRP1_view
    MRP1
    FORM FILL_MRP1_VIEW USING GV_VIEW_CODE.
      CONCATENATE '=' GV_VIEW_CODE INTO GV_OKCODE.
      PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                    '=SP08'.
      IF GV_NXT_VIEW EQ 'SP06'.
        PERFORM BDC_DYNPRO      USING 'SAPLMGMM' '0081'.
        PERFORM BDC_FIELD       USING 'RMMG1-LGORT'
                                       IT_FINAL-TLGORT.
        PERFORM BDC_FIELD       USING 'RMMG1_REF-LGORT'
                                       IT_FINAL-SLGORT.
        PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                      '=ENTR'.
        CLEAR GV_NXT_VIEW.
      ENDIF.
      PERFORM BDC_DYNPRO      USING 'SAPLMGMM' '3006'.
      PERFORM BDC_FIELD       USING 'MARC-LGPRO'
                                    IT_FINAL-LGPRO.
      PERFORM BDC_FIELD       USING 'MARC-LGFSB'
                                    IT_FINAL-LGFSB.
      IF GV_VIEW_COD

  • ABAB programm to copy material sales text from one sales org to another?

    Hi all,
    i'm searching for a ABAP programm to copy a material sales text from one sales org to another.
    Has anybody seen something like that before or has anybody an idea how to do this?
    Greetings & TIA
    strobbel

    @Narin
    I've tried to execute both code now over a new programm in the se38 and i get a error message from the first code (http://www.sap-img.com/abap/bapi-to-copy-materials-from-one-plant-to-another.htm).
    It's called:
    "BAPI_MARC1" cannot be converted to a character-type field.
    Could you help me to solve this?
    Sorry but i'm an absolutely newbie in things like ABAP and so on ...

  • FM to copy material master data

    Hi there
    I am looking for an FM where i can copy existing material master data to a new one. In my case the material is a material variant and therefore i also want to copy the characteritic values of this variant. While copying i want to change some of the characeristic values of my oroginal material master, so that the only difference to the new material variant are characteritic values. All other date (sales, plant and so on) can be the same
    Regards
    Markus

    <b>If you want to copy the properties of material A to material B</b>
    first copy the FM
    goto se37>Press cntrl+f5>enter the from and to FM and FG and press ok.
    <b>BAPI to Copy Materials from one Plant to Another</b>
    http://www.sap-img.com/abap/bapi-to-copy-materials-from-one-plant-to-another.htm
    regards,
    srinivas
    <b>*reward for useful answers*</b>

  • Unable to copy material or import Word Doc into RoboHelp 9 (Suite 3)?

    I had this problem for awhile until I discovered that I was trying to import material from older word documents. Just opening the word doc in Office 10, saving it as a docx file before trying to copy and paste cleared this up. Pictures and text come across easily in RoboHelp 9 and Photoshop now.
    PDF files are hit and miss. I think it may be due to the same type of problem... earlier version creation on the part of the PDF. sometimes they import great, just like they look in PDF format, sometimes they don't are are a big mess. I have had to copy and paste sections, recreating the look of the original pdf in a RoboHelp page.
    Backwards compatability seems to be an issue that keeps cropping up in this suite... or am I doing something wrong, missed a simple control somewhere?

    I think you mean Office 2010. Office 10 is Office 2002,
    I'm not quite clear whether you mean import in the sense of File > Import or copy and paste as you refer to both. File > Import from older versions has not given me any problems. Cut and paste is not something I do much of but again it hasn't given me problems.
    Cut and paste doesn't require any instructions. Importing is covered on my site.
    See www.grainge.org for RoboHelp and Authoring tips
    @petergrainge

  • Price update from Original Material to copied Material Master

    I have a scenario,
    We are selling Raw materials to outside companies who have shortage of materials on Loan Basis. Once they have materials, they will return the materials within a time period. If they don't have the materials and unable to return within the said time, they will make the payment.
    We will follow the normal sales process to sell the item to the customer.
    1. creating sales order,
    2. Outbound Delivery, and
    3. Billing
    Return process when receiving the materials from the company.
    1. Billing Cancellation
    2. PGI Cancellation
    Since this is not an actual sale, hence we need to maintain selling price same as the purchase price.
    We are planning to extend the Raw Materials to Sales View in the material master. However, we came to know that this will be Violation of Act. Hence we are planning to create a new material by copying the existing Raw Material master but the Material type will be Issue on Loan. This material will have sales view and purchase view.
    This material will have a separate Valuation Class. Price control indicator will be V, since the item should be valuated at Purchase Price and the purchase price will keep changing as and when the price changes. This moving average price will be used as selling price.
    The same price needs to be updated in the Sales Order automatically from the Loan Material Master when selling the Loan Material.
    Now, the problem we are facing is, if we create a new Loan Material by copying Raw Material master with ROH material type, how will the price update in New Loan Material since, we will not purchase the Loan Material. We are purchasing the original item as raw material. Hence, this will not update the Loan Material Price automatically and the price will remain unchanged.
    Please suggest a work around?

    Hi,
    Let me explain to you how I am proceeding.
    Step 1:
    Create new material master by copying existing Raw Material with Issue on Loan material type. I am assigning a new Valuation Class in this material master. Also, we keep the pricing
    Step 2:
    Transfer stock from old material to new material in MB1B with movement type 309.
    Step 3: Issue of Loan Material to Customer on loan basis.
    Creating Sales Order, PGI and Billing
    Step 4: Receipt of Item back from Customer
    Sales Return process.
    Step 5: In case Customer does not return goods, then we will collect payment from them
    In the entire process we need to maintain the selling price at purchase price of the original material. Can you suggest any work around, in case this process is not advisable.

Maybe you are looking for

  • Template for users without Adobe

    I have a fairly complicated design challenge I'm trying to work out.  I work as the inhouse designer for a small dental office and they present "before" and "after" photos to their patients with braces.  I've been asked to create a fun background ima

  • Importing XML files into FCP 6

    I recorded some footage using a Panasonic P2camera. I sent the files across to my media drive using fire wire but when I try to import the XML files from my media drive into FCP it tells me: *Please choose a translation document file*. Do I need a dr

  • TDS on Foreign payment

    Hi All, while doing invoice on foreign vendors system deducts tds on Fractions it is effect to my TDS filing in NSDL. how to roundoff TDS on Foreign payments.

  • How can build BMM with multiple fact tables

    HI Gurus, I have 4 fact tables and 18 Dimension table. Dimension tables have links with multiple fact tables. i have created physical joins in Physical layer. Now my questions is how can i create Business Model with multiple fact tables. i mean shoul

  • Drivers do not get installed

    I am using the hugely popular method of creating OS > Architecture > Make > Model hierarchy in Out-of-box drivers then within task sequence setting DriverGroup001 to path above (Windows 7 x64\%Make%\%Model%) and setting Inject Drivers to Nothing. htt