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

Similar Messages

  • BAPI to create Material master record

    Hi All,
    I need to create a new material master record using a reference Mterial number. Please let me know, if there is any BAPI to achieve this.

    Hi,
    Check these links .You will get your answer in detail.
    Re: How to use BAPI BAPI_MATERIAL_SAVEDATA
    Re: Mass creation of Material Master Records
    Hope it will help you.
    Regards:
    Alok

  • Close period for material Master record error

    my current period is 07 2010.
    I want to close period 07 2010, and make new posting to period 08 2010.
    but when i do the posting, system show error "Posting only possible in periods 2010/07 and 2010/06 in company code C999"
    PS: C999 is the company code that contains the plant P999
    And when i try to close the current period of material Master record  by MMPV, system show below information :
    "L O G
    Mode: Check and close period
    Client: 000
    Period entered (month/year): 07 2010
    Incorrect period in control rec. of CoCd C999; no conversion The current period (month/year) of the control record is 07 2010
    Period closing complete; log issued.
    E N D"
    and my current OB52 setting is below:
    Please help to supply some suggestion.
    P999     +               1     2010     12     2010     13     2010     16     2010
    P999     A          ZZZZZZZZZZ     1     2010     12     2010     13     2010     16     2010
    P999     D          ZZZZZZZZZZ     1     2010     12     2010     13     2010     16     2010
    P999     K          ZZZZZZZZZZ     1     2010     12     2010     13     2010     16     2010
    P999     M          ZZZZZZZZZZ     1     2000     12     2010     13     2000     16     2010
    P999     S          ZZZZZZZZZZ     1     2010     12     2010     13     2010     16     2010
    V001     +               1     2000     12     2010     13     2000     16     2010

    Hi,
    Check in T.code: MMRV and see which period is open for ur Co.Code and back posting is allowed or not. If you are sure to open new period now of  new posting to period 08, then
    use t.code: MMPV ,
    enter
    Company code C999
    Period to open 08
    Fiscal Year 2010
    Execute
    ( system will close the period last period 07 and automatically system open the new one 08)
    Now try ur transaction.
    if any problem, then check  in FI Side:
    Use t.code: OB52 and open the 08,2010 period in Account Types A, K, D,M, S and specially Account Type u201C+u201D which stands for valid for all accounts type and save. Better consult FICO consultant for OB52 step.
    Regards,
    Biju K

  • How to enter a material on SO without a Material Master Record?

    Hi guys,
    Pls help me 2 flowing problem:
    1. How to enter a material on SO without a Material Master Record? And all case need to enter a material on SO without a Material Master Record.
    2. How to use customer material number if there isn't Master Data
    Thanks

    Hi Friend,
    I dont think we can go with a sales order with a material without material master record.
    But there are some cases where in we can create a sales order by entering a material which does not have a material master.
    1. Through material determination
    You can create a material determination for a material (1234) which exists in sap by a material(XYZ) which does not; For example in VB11 you can create a material determination for a material 1234 ( exists in sap) through a material XYZ which does not exists in sap.
    While creating the sales order when you enter the material XYZ is not give any error and automatically determine the material 1234 which exists.
    2. Text material
    We can create a order/quote by directly entering a text in the material description and without entering the material. This the case for text material wherein text item category will be determined.
    Please let me know if this help you. Else kindly elaborate the scenario.  
    Abhishek

  • Mass update of huge list of Material master records

    Hi dudes,
    I want to update 1 field for the huge list of  material master record, i.e., statistics field in sales org 2 tab.
    please help
    regards,
    madhav

    SAP has designed its system to use the standard transaction way to update any fields, no direct table update should be made.
    I have seen so many direct table updates in my career, and what do you think why I have get knowledge about that?
    Because it was done incorrectly.
    There are that many dependcies in SAP, you never really know them all.
    People changed (or deleted entries) in one table, but forgot the update in a second dependend table.
    You should be a very experience consultant before you may consider direct table updates, and when you became an experience consultant, then you know that you will not do that.

  • Re: Populating Additional data in Material master record

    Hi,
    I am creating material master record using BAPI_MATERIAL_SAVE_DATA. I am using the below function modules to populate date in Additional Data Tab. I am getting the existing material details from BAPI_MATERIAL_GET_ALL and passing it to
    BAPI_MATERIAL_SAVE_DATA variables. I can create material successfully, but  "PROPORTION/PRODUCT UNIT"   TAB in Additional Data Tab is not populating.
    Program populates this data  for some materials and for some materials not.  For example,  when I try to create a new  material by copying  existing details from 1234 , New material will be created   with 12345(say), but "PROPORTION/PRODUCT UNIT"   TAB in Additional Data Tab is not populating.
    Now If I put a break point, to find out what could be the issue , and then press f6 ,  and re-execute program for the same material 1234, then my custom program can populates data.  I know its sound wiered, but I am not able to solve the issue.
        CALL FUNCTION 'VBWS_UOM_READ_WITH_MATNR'
          EXPORTING
            i_matnr         = it_mara-matnr
          TABLES
            e_meinh         = gt_meinh
            e_meinh_ws      = gt_meinh_ws
            e_meinh_ws_upd  = gt_meinh_ws_upd
            e_meinh_ws_updx = gt_meinh_ws_updx
            e_message       = gt_message
            e_return        = gt_return
          EXCEPTIONS
            error           = 1
            OTHERS          = 2.
        FREE: gt_message, gt_return.
        CLEAR : gt_meinh_ws_upd, gt_meinh_ws_updx.
        CALL FUNCTION 'VBWS_UOM_MAINTAIN_DARK'
          EXPORTING
            i_matnr               = lv_matnr
            i_kzwsm               = it_mara-kzwsm
            i_kzwsmx              = 'X'
            i_exit_by_first_error = 'X'
            i_user                = sy-uname
            i_buffer_refresh      = 'X'
            i_no_update           = ' '
          TABLES
            i_meinh_ws_upd        = gt_meinh_ws_upd[]
            i_meinh_ws_updx       = gt_meinh_ws_updx[]
            e_message             = gt_message
            e_return              = gt_return
          EXCEPTIONS
            error                 = 1
            OTHERS                = 2.
        LOOP AT gt_return WHERE type = 'S'.
          CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
        ENDLOOP.
    Any suggestions ...

    Hi Karthik,
    Thanks for your reply. It worked. But now I am facing strange issue. As you see my code above, i am using VBWS_UOM_MAINTAIN_DARK to update Addition data tab. however, the values of internaltable gt_meinh_ws_upd was not updated correctly inside the material master.
    For example, I am filling gt_meinh_ws_upd table with the below values
    gt_meinh_ws_upd-wsm = 'OZT'
    gt_meinh_ws_upd-atnam ' ZABCDE'
    gt_meinh_ws_upd-atwrt = 0.0023
    append gt_meinh_ws_upd.
    but when i see in material master,   gt_meinh_ws_upd-atwrt = 0.0023 is updated with 23, instead of 0.023. I debugged th func. module many times, I didnot come acroos the code what making it to 23.
    Any Idea karthik...
    Thanks in Advance

  • PR, PO, GR for a consumable material without material master record

    Hi,
    I have created a complete cylcle till Invoice Verification for a material without a material master record.
    But i have one query i.e. in the cylce i created i had to create a GR before entering MIRO.  Is there any way by which i need not create a GR for a consumable material i.e. to be posted directly to a GL without any inventory management.
    In my case, the GR checkbox in the PO was automatically ticked.
    Can anyone help on this please.
    Regards,
    Laxmi

    Customizing Error Message in ME23N
    When displaying of modifying Purchase Orders with a document type of Framework Order,  a user selects the LIMITS tab, they get the error message Customizing incorrectly maintained, message number SE729.
    The problem is caused by version upgrades of the SAP software.
    Number of entries in table T162V is different to the number of columns in table control for screen SAPLMLSP (400).  You can use screen painter SE51 to display the screen.  View the Element list for TC_VIEW.
    The list of fields can also be viewed within the program.  Transaction code ML81N (service entry sheet), program SAPLMLSR.  Click on the Configuration button (top right hand corner) select Administrator.  This shows the number of fields as 67.
    Using SE16N to view table T162V shows 69 fields.  This table contains six layouts (variants), they must all be the same.  Before the change the total count was 414 (69 x 6). 
    The ME23N transaction only checks that the number of entries is correct.  You will notice that the fields are not in the same sequence, but that should not matter if you donot use the service transaction ML81N and it is not a selectable tab on ME23N.
    Transaction SM31 was used to delete the extra fields.  As this is a SAP table, you may need extra authorisations to make the change.
    Note:  the number of fields shown above will be different in each site.  This is because of different SAP versions and in what software is loaded. 

  • Product hierarchy in the material master record

    Hi,
    I am handig Data migration project.
    This is related to Product Hirerarchy.
    I one business Product Hirerarchy have been configured. But in another buisiness, Product Hirerarchy has not been configured.
    There are some common materials using by both business processes.
    For coomon mateials  if I am maintaining Product Hirerarchy value in the material master record, is there any impact on business which is not being used Product Hirerarchy. Whether it will stop / impact on business processes.
    Can you explain plz
    Thanks in advance
    Regards

    Hi karthink,
    Thanks for your inputs.
    we are meging two servers. In that in one server, product highrechy have been configuredand in another server not configured.
    There are some materials with the numbers calling as a common parts exists in both servers.
    ex: plat 0001 in one server 1         &          plant 0002 in server2
    Common part is : m1
    plant 0001  not using product hierarchy and plant 0002 not using product hierarchy,.
    After golive, all the common parts are being used by both plants and same basic data 1 view.
    If we are maintaing product hierarchy in the basic data 1 view, it will flow into sales view as well.
    Then what about impact on the plant 0001 business since it is not using product hierarchy.
    In the configuration, is there any settings to activate / deactive product hierarchy at sales area level.
    Is there any impact on MM / FICO side.
    Please explain.
    THANKS IN ADVANCE.
    Regards
    KRK

  • Material without material master record

    Dear All,
    i want material without material master record by using account assignment category k. how can i do that. item category should be standard. i will use another material group with a different valuation class.
    regards,
    qsm sap

    Hi,
    In ME21N, In case of w/o material master purchases (Text Purchases), do not enter material code in PO, Enter following details;
    Account Assignment Category (For e.g. K - Cost Center),
    Item Category - Blank
    Short Text,
    Quantity,
    UoM,
    Material Group,
    Plant,
    Gross Price, etc...
    Then Save it.
    2. MIGO - GR w.r.t. PO
    It will Debit Expense A/c and Credit GR/IR Clearing A/c.
    3. MIRO - LIV w.r.t. PO
    It will Credit Vendor A/c and Debit GR/IR Clearing A/c.
    And if you want account determination on the basis of material group then do following config.
    SPRO > MM > Purchasing > Material master > Entry Aids for Items without an material master > here assign different valuation classes to different material groups as per your Accounting requirement.
    And then do necessary account determination in OBYC for the Valuation classes, T/E Key "GBB" and Val. modifier "VBR"
    Also refer the following link;
    [Default GL account in account assigned Purchase Documents|http://www.sap123.com/showthread.php?t=10]

  • How to load AFS Material Master records.

    Hello everyone,
    I am new to loading AFS Material Master records.  In the past I have simply used the Material Master direct input programs, or batch input, to load the data.  Because of the extra AFS fields, I was guessing there must be a new direct input program, or batch input, for it.  Maybe there is a IDOC that must be used?
    Any help will be appreciated.  Thank you all.

    Hey there again, I just wanted to bring this subject back up again. 
    I always took it for granted the we loaded materials in batches.  We would load basic data for some materials and then extend the plant data, then sales, storloc data, warehouse data.  That is a total of 5 files one after the other.  I never really thought of why we did this, but now that I think about it maybe we did because it only took a little bit of data to create the basic data.  When you extend the plant data, you do not need to enter in the data already created from the initial basic data load.  Sales data only required so much so you could skip all the unnecessary basic and plant data. 
    Is that why  you loaded in batches, because it is easier to extend? 
    If you wanted to you could have all the basic, plant, sales, purchasing data on one record if you really wanted to.  Why didnu2019t you do it that way?
    Thanks for the input.

  • Material master records

    Hi,
       i tried  to initialize period for material master record and i am getting error  * follow the instruction in note 487381 before initialization* .any suggestion would be appriciated thanks
    cheers
    jothi

    Hi
    FYI--from sap note
    the initialization of a posting period has the following effects concerning the period stocks:
    The initialization of the posting period to a previous or to any posting period may lead to the loss of the information of the inventory balances of the previous periods.The book value of the current posting period is taken as the basis also for values of the previous period in this case.
               If you want to continue working with this new posting period, in addition you should execute report Z_DEL_HIST_ENTRIES attached so that history entries greater or equal to the new posting period will be deleted.
    If you have to briefly reset the posting period by one period (for example, postings must still be posted in a certain period) just to make a correction (and for a small number of postings), you should initialize the posting period back again to the old value so that the values of the previous period will not be lost (you should forbid postings when carrying out corrections).
               However, afterwards the values of the previous period or the history records (as of Release 4.5) of the materials posted in this case are inaccurate.
               You should NOT execute report Z_DEL_HIST_ENTRIES in this case.
    However, if the posting period is generally reset again to a previous posting period and if postings were made during this time, all information on the inventory balance of the previous periods is lost.
               As of Release 4.5a, you should use the cited correction report Z_DEL_HIST_ENTRIES in order to delete history records that are more current than the current posting period.Otherwise, it can result in deviations (inconsistencies) for the update of the history records.
    Important! If there are open physical inventory documents that have status 'counted' or for which indicator 'Freeze inventory balance' has been set, you should reject these if they refer to a previous period or have been created in the former previous period.The inventory difference to be posted can be determined from the current book value of the previous period and the book quantity frozen in the physical inventory document (ISEG-BUCHM) and does not match the inventory balance of the previous period that is currently valid.
    Reg
    Raja

  • Activities to be done before a Material Master record archiving

    I read that "before a material master record can be archived and deleted, other objects (such as purchasing documents) that refer to this material must themselves be archived". How can I see which objects these are and the dependencies between them?
    What other activities should be done before a Material Master record archiving?
    Thank you very much!

    go SARA
    enter MM_MATNR
    click the button for NETWORK  (first position in application toolbar)
    SAP will show you all objects that you need to take care with archiving before you can archive a material.
    You can execute a test run for archiving, and SAP will tell you in the error log, what dependencies a specific  material  has.
    Before your archive, make sure you have the most recent OSS notes applied.

  • How do I find who created a particular material master record?

    How can I find who created a material master record when it was created?  I've looked in the item changes log and all it shows is changes, not when the material was created.
    Thanks!

    Hi,
    You can use SE16 + MARA. Field ERSDA will show you the desired date.
    In MM03 there's an icon: white 'i', background blue. Please click on it.
    BR
    Csaba

  • Mass Material Master Records Extension

    Hi All,
    Mass Material Master Records Extension
    I have a list of 50 materials.
    I want to extend them to new sales areas and plants.
    Is there a t-code for mass extension of material master records,
    Please advice
    thanks in advance
    Rgds
    Priyanka

    The Options are:
    1. LSMW
    2. SCATT
    3. BDC
    It is not recommended through MM17 ot MASS.
    Abap help can be taken to develop the BDC / LSMW accordingly.
    Regards,
    Rajesh Banka
    Reward suitable points.
    How to give points: Mark your thread as a question while creating it. In the answers you get, you can assign the points by clicking on the stars to the left. You also get a point yourself for rewarding (one per thread).

  • Price Control Indicator in Material Master Record (Accounting View1)

    Hi,
    Is there any way to make the Standard Price (S) or Moving Average Price (V) automatically SET in Material Master Record? So that everytime we create a material, there will be no need to enter which price we prefer.

    Hi,
    Go to OMS2. select material type- goto detail- Tick 'Price control Mandatory".
    Also if you maintain "ext pro allowed i,e,2" ,system will pick price control V automatically.
    For price control S, maintain Int proc allowed as 2.
    Regards,
    Piyush
    Edited by: Piyush Mishra on Jul 20, 2010 9:06 AM

Maybe you are looking for