About material master data batch input

hello
    i wrote a batch input for material master data. but it can't work ,i can't use it to create material.hope someone help me!thanks.code is below.
report z_mat_batchinput no standard page heading
      line-size 255 message-id YB.
       mat batch input
include bdcrecx1.
include .
tables: mara,marm,MARC,MARD,T134,NRIV,T006A,T023,T001W,T001L,
        TVKO,TVTW,T025,TTGR,TLGR,TVKWZ,T006.
data: DIMID like t006-DIMID.
data: flag, K, tmp.
DATA: X TYPE I.
************ÉÏÔØÎļþÄÚ±í************************
data: begin of record occurs 0,
        MATNR(018),        " ÎïÁϺÅ
        MTART(004),        " ÎïÁÏÀàÐÍ
**generaldata1**
        MAKTX(040),        " ÎïÁÏÃèÊö
       EAKTX(040),        " Ó¢ÎÄÃèÊö
        MEINS(003),        " »ù±¾¼ÆÁ¿µ¥Î»
        MATKL(009),        " ÎïÁÏ×é
        BISMT(018),        " ¾ÉÎïÁϺÅ
       EXTWG(018),        " ÍⲿÎïÁÏ×é
       SPART(002),        " ²¿ÃÅ
        MTPOS_MARA(004),   " ÆÕͨÏîÄ¿Àà±ð×é
        BRGEW(017),        " ëÖØ
        GEWEI(003),        " ÖØÁ¿µ¥Î»
        NTGEW(017),        " ¾»ÖØ
        VOLUM(017),        " Ìå»ý
        VOLEH(003),        " Ìå»ýµ¥Î»
        GROES(032),        " Á¿¸Ù
        MAGRV(004),        " ÎïÁÏ×éµÄ°ü×°Îï
**generaldata2**
        NORMT(018),        " ¹¤Òµ±ê×¼ÃèÊö
        FERTH(018),        " ÀàÐÍ
        WRKST(048),        " ¹æ¸ñ
**generaldata1**
       EAN11(018),        " ²úÆ·±íʶÂë
**generaldata2**
       ZEIAR(003),        " ÎĵµÀàÐÍ£¬ºÏÀí´¢±¸ÖÜתÆÚ
        WERKS(004),        " ¹¤³§
        VKORG(004),        " ÏúÊÛ×éÖ¯
        VTWEG(002),        " ·ÖÏúÇþµÀ
**salesorg 1**
       VRKME(003),        " ÏúÊÛµ¥Î»
       VMREN(006),        " ÏúÊÛµ¥Î»×ª»»Òò×Ó
       VMREZ(006),        " »ù±¾µ¥Î»×ª»»Òò×Ó
        SPART(002),        " ²úÆ·×é
        DWERK(004),        " ½»»õ¹¤³§
        TAXKM(001),        " ÎïÁÏË°·ÖÀà
**salesorg 2**
        KONDM(002),        " ÎïÁ϶¨¼Û×é
        KTGRM(002),        " ¿ÆÄ¿ÉèÖÃ×é
       MVGR1(003),                                         " ÎïÁÏ×é 1
       MVGR2(003),                                         " ÎïÁÏ×é 2
        MTPOS(004),        " ÏîÄ¿Àà±ð×é
       VERSG(001),        " ÎïÁÏͳ¼Æ×é
**ÏúÊÛ£ºÒ»°ã/¹¤³§Êý¾Ý**
        MTVFP(002),        " ¿ÉÓÃÐÔ¼ì²é
        XCHPF(001),        " Åú´Î¹ÜÀí
       YCHPF(001),        " ÅúÁ¿¹ÜÀí
        TRAGR(004),        " ÔËÊä×é
        ladgr(004),        " ×°ÔØ×é
**pur**
       BSTME(003),        " ¶©µ¥µ¥Î»
       UMREZ(006),        " »ù±¾µ¥Î»×ª»»Òò×Ó
       UMREN(006),        " ¶©µ¥µ¥Î»×ª»»Òò×Ó
       WEBAZ(003),        " ÊÕ»õ´¦Àíʱ¼ä
        EKGRP(003),        " ²É¹º×é
      LGORT(004),        " ¿â´æµØ
**Ò»°ã¹¤³§Êý¾Ý/²Ö´¢1**
       AUSME(003),        " ·¢»õµ¥Î»
       UMREJ(006),        " »ù±¾µ¥Î»×ª»»Òò×Ó
       UMREF(006),        " ·¢»õµ¥Î»×ª»»Òò×Ó
       XCHPF(001),        " ÅúÁ¿¹ÜÀí
**MRP 1**
       DISGR(004),        " MRP×é
        DISMM(002),        " MRPÀàÐÍ
       FXHOR(003),        " ¼Æ»®µÄʱ½ì
        DISPO(003),        " MRP¿ØÖÆÕß
        DISLS(002),        " ÅúÁ¿
        MAABC(001),        " ABC±êʶ
       BSTFE(018),        " ¹Ì¶¨ÅúÁ¿´óС
**MRP 2**
       RESKZ(001),        " »ñÈ¡ÀàÐÍ
        BESKZ(001),        " ²É¹ºÀàÐÍ
       SOBSL(002),        " ÌØÊâ²É¹ºÀà
       LGPRO(004),        " ·¢»õ²Ö´¢µØµã
       RGEKZ(001),        " ·´³å
        PLIFZ(003),        " ¼Æ»®½»»õʱ¼ä
       VEBAZ(003),        " ÊÕ»õ´¦Àíʱ¼ä
        DZEIT(008),        "×ÔÖÆÉú²ú
        FHORI(003),        " ¼Æ»®±ß¼ÊÂë
       EISBE(018),        " °²È«¿â´æ
**MRP 3**
        PERKZ(001),        " ÆÚ¼ä±êʶ
        STRGR(002),        " ²ßÂÔ×é
       VRMOD(001),        " ÏûºÄģʽ
       VINT1(003),        " ÄæÏòÏûºÄÆÚ¼ä
       VINT2(003),        " ÏòÇ°ÏûºÄÆÚ¼ä
        NTVFP(002),        " ¿ÉÓÃÐÔ¼ì²é
**MRP 4**
       SAUFT(001),        " Öظ´ÖÆÔì±êÖ¾
       SFEPR(004),        " Öظ´Éú²ú²ÎÊýÎļþ
**¹¤×÷¼Æ»®**
       FEVOR(003),        " Éú²úµ÷¶ÈÔ±
       FRTME(003),        " Éú²úµ¥Î»
       SMREZ(006),        " »ù±¾µ¥Î»×ª»»Òò×Ó
       SMREN(006),        " Éú²úµ¥Î»×ª»»Òò×Ó
       UEETK(001),        " ÎÞÏÞÖƹýÁ¿½»»õ
**»á¼Æ 1**
        BKLAS(004),        " ÆÀ¹ÀÀà
       BWTTY(001),        " ¹À¼Û·ÖÀà
        VPRSV(001),        " ¼Û¸ñ¿ØÖÆ
        PEINH(006),        " ¼Û¸ñµ¥Î»
        VERPR(015),        " Òƶ¯Æ½¾ù¼Û
        STPRS(015),        " ±ê×¼¼Û
**»á¼Æ 2**
       BWPRH(014),        " ÉÌÒµ¼Û¸ñ 1
**³É±¾ 1**
       LOSGR(018),        " ÅúÁ¿³É±¾ºËËã
**³É±¾ 2**
       ZPLP1(014),        " ¼Æ»®¼Û¸ñ 1
       ZPLD1(010),        " ¼Æ»®ÈÕÆÚ 1
**qm**
        ART1(8),            "¼ìÑéÀàÐÍ1
        AKTIV1(1),          "ÒѼ¤»î
        QMPUR(1),             "¼¤»î²É¹ºÖÐµÄ QM
        SSQSS(8),          "QM ¿ØÖÆÂë¡¢
       QMATV(8),          "QM¼ìÑéÉèÖÃ
       ART2(8),            "¼ìÑéÀàÐÍ2
       AKTIV2(6),          "ÒѼ¤»î
       ART3(8),            "¼ìÑéÀàÐÍ3
       AKTIV3(6),          "ÒѼ¤»î
      end of record.
************ÏÂÔظñʽ/´íÎóÎļþÄÚ±í**************
data: begin of record1 occurs 0,
        MATNR(018),        " ÎïÁϺÅ
        MTART(008),        " ÎïÁÏÀàÐÍ
**»ù±¾Êý¾Ý1**
        MAKTX(040),        " ÎïÁÏÃèÊö
       EAKTX(040),        " Ó¢ÎÄÃèÊö
        MEINS(013),        " »ù±¾¼ÆÁ¿µ¥Î»
        MATKL(009),        " ÎïÁÏ×é
        BISMT(018),        " ¾ÉÎïÁϺÅ
       EXTWG(018),        " ÍⲿÎïÁÏ×é
       SPART(002),        " ²¿ÃÅ
        MTPOS_MARA(004),   " ÆÕͨÏîÄ¿Àà±ð×é
        BRGEW(017),        " ëÖØ
        GEWEI(008),        " ÖØÁ¿µ¥Î»
        NTGEW(017),        " ¾»ÖØ
        VOLUM(017),        " Ìå»ý
        VOLEH(008),        " Ìå»ýµ¥Î»
        GROES(032),        " Á¿¸Ù
        MAGRV(014),        " ÎïÁÏ×éµÄ°ü×°Îï
**»ù±¾Êý¾Ý2**
        NORMT(018),        " ¹¤Òµ±ê×¼ÃèÊö
        FERTH(018),        " ÀàÐÍ
        WRKST(048),        " ¹æ¸ñ
**»ù±¾Êý¾Ý1**
       EAN11(018),        " ²úÆ·±íʶÂë
**»ù±¾Êý¾Ý2**
       ZEIAR(003),        " ÎĵµÀàÐÍ£¬ºÏÀí´¢±¸ÖÜתÆÚ
        WERKS(004),        " ¹¤³§
        VKORG(008),        " ÏúÊÛ×éÖ¯
        VTWEG(008),        " ·ÖÏúÇþµÀ
**ÏúÊÛ×éÖ¯ 1**
       VRKME(003),        " ÏúÊÛµ¥Î»
       VMREN(006),        " ÏúÊÛµ¥Î»×ª»»Òò×Ó
       VMREZ(006),        " »ù±¾µ¥Î»×ª»»Òò×Ó
        SPART(006),        " ²úÆ·×é
        DWERK(008),        " ½»»õ¹¤³§
        TAXKM(010),        " ÎïÁÏË°·ÖÀà
**ÏúÊÛ×éÖ¯ 2**
        KONDM(010),        " ÎïÁ϶¨¼Û×é
        KTGRM(010),        " ¿ÆÄ¿ÉèÖÃ×é
       MVGR1(003),                                         " ÎïÁÏ×é 1
       MVGR2(003),                                         " ÎïÁÏ×é 2
        MTPOS(010),        " ÏîÄ¿Àà±ð×é
       VERSG(001),        " ÎïÁÏͳ¼Æ×é
**ÏúÊÛ£ºÒ»°ã/¹¤³§Êý¾Ý**
        MTVFP(010),        " ¿ÉÓÃÐÔ¼ì²é
        XCHPF(008),        " Åú´Î¹ÜÀí
       YCHPF(001),        " ÅúÁ¿¹ÜÀí
        TRAGR(006),        " ÔËÊä×é
        ladgr(006),        " ×°ÔØ×é
**²É¹º**
       BSTME(003),        " ¶©µ¥µ¥Î»
       UMREZ(006),        " »ù±¾µ¥Î»×ª»»Òò×Ó
       UMREN(006),        " ¶©µ¥µ¥Î»×ª»»Òò×Ó
       WEBAZ(003),        " ÊÕ»õ´¦Àíʱ¼ä
        EKGRP(006),        " ²É¹º×é
      LGORT(004),        " ¿â´æµØ
**Ò»°ã¹¤³§Êý¾Ý/²Ö´¢1**
       AUSME(003),        " ·¢»õµ¥Î»
       UMREJ(006),        " »ù±¾µ¥Î»×ª»»Òò×Ó
       UMREF(006),        " ·¢»õµ¥Î»×ª»»Òò×Ó
       XCHPF(001),        " ÅúÁ¿¹ÜÀí
**MRP 1**
       DISGR(004),        " MRP×é
        DISMM(009),        " MRPÀàÐÍ
       FXHOR(003),        " ¼Æ»®µÄʱ½ì
        DISPO(011),        " MRP¿ØÖÆÕß
        DISLS(004),        " ÅúÁ¿
        MAABC(007),        " ABC±êʶ
       BSTFE(018),        " ¹Ì¶¨ÅúÁ¿´óС
**MRP 2**
       RESKZ(001),        " »ñÈ¡ÀàÐÍ
        BESKZ(008),        " ²É¹ºÀàÐÍ
       SOBSL(002),        " ÌØÊâ²É¹ºÀà
       LGPRO(004),        " ·¢»õ²Ö´¢µØµã
       RGEKZ(001),        " ·´³å
        PLIFZ(012),        " ¼Æ»®½»»õʱ¼ä
       VEBAZ(003),        " ÊÕ»õ´¦Àíʱ¼ä
        DZEIT(008),        "×ÔÖÆÉú²ú
        FHORI(010),        " ¼Æ»®±ß¼ÊÂë
       EISBE(018),        " °²È«¿â´æ
**MRP 3**
        PERKZ(008),        " ÆÚ¼ä±êʶ
        STRGR(006),        " ²ßÂÔ×é
       VRMOD(001),        " ÏûºÄģʽ
       VINT1(003),        " ÄæÏòÏûºÄÆÚ¼ä
       VINT2(003),        " ÏòÇ°ÏûºÄÆÚ¼ä
        NTVFP(010),        " ¿ÉÓÃÐÔ¼ì²é
**MRP 4**
       SAUFT(001),        " Öظ´ÖÆÔì±êÖ¾
       SFEPR(004),        " Öظ´Éú²ú²ÎÊýÎļþ
**¹¤×÷¼Æ»®**
       FEVOR(003),        " Éú²úµ÷¶ÈÔ±
       FRTME(003),        " Éú²úµ¥Î»
       SMREZ(006),        " »ù±¾µ¥Î»×ª»»Òò×Ó
       SMREN(006),        " Éú²úµ¥Î»×ª»»Òò×Ó
       UEETK(001),        " ÎÞÏÞÖƹýÁ¿½»»õ
**»á¼Æ 1**
        BKLAS(006),        " ÆÀ¹ÀÀà
       BWTTY(001),        " ¹À¼Û·ÖÀà
        VPRSV(008),        " ¼Û¸ñ¿ØÖÆ
        PEINH(008),        " ¼Û¸ñµ¥Î»
        VERPR(015),        " Òƶ¯Æ½¾ù¼Û
        STPRS(015),        " ±ê×¼¼Û
**»á¼Æ 2**
       BWPRH(014),        " ÉÌÒµ¼Û¸ñ 1
**³É±¾ 1**
       LOSGR(018),        " ÅúÁ¿³É±¾ºËËã
**³É±¾ 2**
       ZPLP1(014),        " ¼Æ»®¼Û¸ñ 1
       ZPLD1(010),        " ¼Æ»®ÈÕÆÚ 1
**ÖÊÁ¿¹ÜÀí**
        ART1(8),            "¼ìÑéÀàÐÍ1
        AKTIV1(6),          "ÒѼ¤»î
        QMPUR(010),             "¼¤»î²É¹ºÖÐµÄ QM
        SSQSS(8),          "QM ¿ØÖÆÂë¡¢
       QMATV(8),          "QM¼ìÑéÉèÖÃ
       ART2(8),            "¼ìÑéÀàÐÍ2
       AKTIV2(6),          "ÒѼ¤»î
       ART3(8),            "¼ìÑéÀàÐÍ3
       AKTIV3(6),          "ÒѼ¤»î
      end of record1.
selection-screen begin of block 0 with frame title text-001.
selection-screen begin of line .
selection-screen position 1.
parameters: test like rkec1-test .
selection-screen
  comment 3(4) text-004 for field test.
selection-screen position 26.
parameters: oldfile like rlgrap-filename.
selection-screen
  comment 9(17) text-003 for field oldfile.
selection-screen: end of line.
selection-screen begin of line.
selection-screen position 1.
parameters: dnldflag like rkec1-test default 'X'.
selection-screen
  comment 3(4) text-005 for field dnldflag.
selection-screen position 26.
parameters: outfile like rlgrap-filename .
selection-screen
  comment 9(17) text-006 for field outfile.
selection-screen: end of line.
selection-screen end of block 0 .
SELECTION-SCREEN BEGIN OF BLOCK 1 WITH FRAME TITLE TEXT-002.
selection-screen begin of line.
selection-screen position 1.
PARAMETERS: GEN1 LIKE RKEC1-TEST.
selection-screen
  comment 3(9) text-007 for field GEN1.
selection-screen position 26.
PARAMETERS: GEN2 LIKE RKEC1-TEST.
selection-screen
  comment 28(9) text-008 for field GEN2.
selection-screen end of line.
selection-screen begin of line.
selection-screen position 1.
PARAMETERS: SALORG1 LIKE RKEC1-TEST.
selection-screen
  comment 3(21) text-009 for field SALORG1.
selection-screen position 26.
PARAMETERS: SALORG2 LIKE RKEC1-TEST.
selection-screen
  comment 28(21) text-010 for field SALORG2.
selection-screen position 51.
PARAMETERS: SALPLANT LIKE RKEC1-TEST.
selection-screen
  comment 53(19) text-011 for field SALPLANT.
selection-screen end of line.
selection-screen begin of line.
selection-screen position 1.
PARAMETERS: PURCHASE LIKE RKEC1-TEST.
selection-screen
  comment 3(21) text-012 for field PURCHASE.
selection-screen position 26.
PARAMETERS: PLTSTRG1 LIKE RKEC1-TEST.
selection-screen
  comment 28(21) text-018 for field PLTSTRG1.
selection-screen end of line.
selection-screen begin of line.
selection-screen position 1.
PARAMETERS: MRP1 LIKE RKEC1-TEST.
selection-screen
  comment 3(4) text-013 for field MRP1.
selection-screen position 13.
PARAMETERS: MRP2 LIKE RKEC1-TEST.
selection-screen
  comment 15(4) text-014 for field MRP2.
selection-screen position 26.
PARAMETERS: MRP3 LIKE RKEC1-TEST.
selection-screen
  comment 28(4) text-015 for field MRP3.
selection-screen position 37.
PARAMETERS: MRP4 LIKE RKEC1-TEST.
selection-screen
  comment 39(4) text-016 for field MRP4.
selection-screen position 51.
PARAMETERS: PLANTSTR LIKE RKEC1-TEST.
selection-screen
  comment 53(8) text-017 for field PLANTSTR.
selection-screen end of line.
selection-screen begin of line.
selection-screen position 1.
PARAMETERS: QAU LIKE RKEC1-TEST.
selection-screen
  comment 3(8) text-023 for field QAU.
selection-screen position 13.
PARAMETERS: ACC1 LIKE RKEC1-TEST.
selection-screen
  comment 15(5) text-019 for field ACC1.
selection-screen position 26.
PARAMETERS: ACC2 LIKE RKEC1-TEST.
selection-screen
  comment 28(5) text-020 for field ACC2.
selection-screen position 37.
PARAMETERS: COR1 LIKE RKEC1-TEST.
selection-screen
  comment 39(5) text-021 for field COR1.
selection-screen position 51.
PARAMETERS: COR2 LIKE RKEC1-TEST.
selection-screen
  comment 53(5) text-022 for field COR2.
selection-screen end of line.
SELECTION-SCREEN END OF BLOCK 1.
at selection-screen on value-request for oldfile.
  call function 'KD_GET_FILENAME_ON_F4'
       EXPORTING
            mask      = ',Îı¾Îļþ(ÖƱí·û·Ö¸ô),*.txt'
            static    = 'X'
       CHANGING
            file_name = oldfile.
at selection-screen on value-request for outfile.
  call function 'KD_GET_FILENAME_ON_F4'
       EXPORTING
            mask      = ',Microsoft Excel¹¤×÷²¾,*.xls'
            static    = 'X'
       CHANGING
            file_name = outfile.
initialization.
******µÃµ½ÎļþĿ¼*******
  call function 'WS_QUERY'
       EXPORTING
            query  = 'CD'
       IMPORTING
            return = outfile.
  if sy-subrc <> 0.
    message e005 with outfile.
  endif.
  oldfile = outfile.
  concatenate outfile 'mat_fat' into outfile.
*ÅúÊäÈëĬÈÏÃû³Æ
  group = 'MATBATCHIN'.
start-of-selection.
  if dnldflag eq 'X' and not ( outfile is initial ).
    perform download_data.
    stop.
  endif.
  perform upload_data.
  if test = ' '.
*ÊÓͼ²ÎÊý¼ì²é
    IF ( GEN1 NE 'X' AND GEN2 NE 'X' AND SALORG1 NE 'X'
       AND SALORG2 NE 'X' AND SALPLANT NE 'X'
       AND PURCHASE NE 'X' AND PLTSTRG1 NE 'X'
       AND MRP1 NE 'X' AND MRP2 NE 'X' AND MRP3 NE 'X'
           AND MRP4 NE 'X' AND PLANTSTR NE 'X'
       AND ACC1 NE 'X' AND ACC2 NE 'X'
       AND COR1 NE 'X' AND COR2 NE 'X' and qau ne 'X' ) .
      MESSAGE E000 WITH 'ÇëÑ¡ÔñÐèά»¤ÊÓͼ'.
    ENDIF.
    perform open_group.
    SORT RECORD BY WERKS MATNR.
    loop at record.
      perform bdc_fill.
      perform bdc_transaction using 'MM01'.
      clear: bdcdata.
      refresh: bdcdata.
    endloop.
    perform close_group.
  else.
    perform file_check.
  endif.
end-of-selection.
*&      Form  UPLOAD_DATA
      ÉÏÔØÅúÊäÈëÊý¾Ý
-->  p1        text
<--  p2        text
form upload_data.
  call function 'WS_UPLOAD'
       EXPORTING
            filename                = oldfile
            filetype                = 'DAT'
       TABLES
            data_tab                = record
       EXCEPTIONS
            conversion_error        = 1
            file_open_error         = 2
            file_read_error         = 3
            invalid_table_width     = 4
            invalid_type            = 5
            no_batch                = 6
            unknown_error           = 7
            gui_refuse_filetransfer = 8
            customer_error          = 9
            others                  = 10.
  if sy-subrc <> 0.
    message E000 with 'ÇëÊäÈëÉÏÔØÎļþ'.
  endif.
  read table record with key MATNR = '**'.
  if sy-tabix lt 1.
    message E000 with 'ÉÏÔØÎļþÎļþÍ·ÓëÊý¾ÝÖ®¼äÎÞ**'.
  endif.
  delete record from 1 to sy-tabix.
endform.                               " UPLOAD_DATA
*&      Form  BDC_FILL
      ÅúÊäÈë
-->  p1        text
<--  p2        text
form bdc_fill.
  data: N type I,
        M type I,
        S_MATNR(018),
        test(1) type N.
  PERFORM BDC_FILL_INITALSCR.    "³õʼÆÁÄ»
  tmp = '0'.
  condense record-matnr no-gaps.
  test =  record-matnr(1).
  if test <> ''.
    M = STRLEN( RECORD-MATNR ).
    M = 18 - M.
    DO M TIMES.
      CONCATENATE '0' RECORD-MATNR INTO S_MATNR.
      RECORD-MATNR = S_MATNR.
    ENDDO.
  endif.
**ÅжÏÎïÁÏ»ù±¾ÊÓͼÊÇ·ñÒѾ±»Î¬»¤¹ý**
  SELECT SINGLE * FROM MARA WHERE MATNR = RECORD-MATNR.
  IF SY-SUBRC NE 0.
    K = '0'.
  Else.
    condense MARA-PSTAT no-gaps.
    N = strlen( mara-pstat ).
    M = 0.
    record-meins = mara-meins.
    do N times.
      K = MARA-PSTAT+M.
      IF K = 'K'.
        EXIT.
      ENDIF.
      M = M + 1.
    enddo.
  ENDIF.
  IF ( ( GEN1 EQ 'X' OR GEN2 EQ 'X' ) AND SALORG1 NE 'X'
     AND SALORG2 NE 'X' AND SALPLANT NE 'X'
     AND PURCHASE NE 'X' AND PLTSTRG1 NE 'X'
     AND MRP1 NE 'X' AND MRP2 NE 'X' AND MRP3 NE 'X'
         AND MRP4 NE 'X' AND PLANTSTR NE 'X'
     AND ACC1 NE 'X' AND ACC2 NE 'X'
     AND COR1 NE 'X' AND COR2 NE 'X' and qau ne 'X' ) .
    IF K EQ 'K'.
      perform bdc_dynpro      using 'SAPLMGMM' '0070'.
      perform bdc_field       using 'BDC_CURSOR'
                                    'MSICHTAUSW-DYTXT(15)'.
      perform bdc_field       using 'BDC_OKCODE'
                                    '/N'.
    ELSE.
      PERFORM BDC_FILL_CHOICEVIEW.   "Ñ¡ÔñÊÓͼ
    ENDIF.
  ELSE.
    PERFORM BDC_FILL_CHOICEVIEW.   "Ñ¡ÔñÊÓͼ
    PERFORM BDC_FILL_ORGVIEW.      "×éÖ¯¼¶±ð
  ENDIF.
  TRANSLATE record-MEINS TO UPPER CASE.
TRANSLATE record-BSTME TO UPPER CASE.
TRANSLATE record-VRKME TO UPPER CASE.
TRANSLATE record-FRTME TO UPPER CASE.
TRANSLATE record-AUSME TO UPPER CASE.
  if gen1 eq 'X'.
    IF K NE 'K'.
      PERFORM GENERALDATA1.
    ENDIF.
  endif.
  if gen2 eq 'X'.
    IF K NE 'K'.
      perform generaldata2.
    ENDIF.
  endif.
  if salorg1 eq 'X'.
    perform salorg1.
  endif.
  if salorg2 eq 'X'.
    perform salorg2.
  endif.
  if salplant eq 'X'.
    perform salplant.
  endif.
  if purchase eq 'X'.
    perform purchasedata.
  endif.
  if mrp1 eq 'X'.
    perform MRP1.
  endif.
  if mrp2 eq 'X'.
    perform MRP2.
  endif.
  if mrp3 eq 'X'.
    perform MRP3.
  endif.
  if mrp4 eq 'X'.
    perform MRP4.
  endif.
  if PLANTSTR eq 'X'.
    perform PLANTSTR.
  endif.
  if PLTSTRG1 eq 'X'.
    perform PLTSTRG1.
  endif.
  if qau eq 'X'.
    perform qualitydata.
  endif.
  if ACC1 eq 'X'.
    perform ACC1DATA.
  endif.
  if ACC2 eq 'X'.
    perform ACC2DATA.
  endif.
  if COR1 eq 'X'.
    perform COR1DATA.
  endif.
  if COR2 eq 'X'.
    perform COR2DATA.
  endif.
  perform BDC_SAVE.
endform.                               " BDC_FILL
*&      Form  GENERALDATA1
      Ò»°ãÊý¾Ý 1
-->  p1        text
<--  p2        text
form generaldata1.
  perform bdc_dynpro      using 'SAPLMGMM' '4004'.
  perform bdc_field       using 'BDC_OKCODE'
                                "'=ZU01'.
                                '/00'.
  perform bdc_field       using 'MAKT-MAKTX'
                                record-MAKTX.       " ÎïÁÏÃèÊö
  perform bdc_field       using 'MARA-MEINS'
                                record-MEINS.       " »ù±¾¼ÆÁ¿µ¥Î»
  perform bdc_field       using 'MARA-MATKL'
                                record-MATKL.       " ÎïÁÏ×é
  perform bdc_field       using 'MARA-BISMT'
                                record-BISMT.
perform bdc_field       using 'MARA-EXTWG'
                               record-EXTWG.
perform bdc_field       using 'MARA-SPART'
                               record-SPART.
  perform bdc_field       using 'MARA-MTPOS_MARA'
                                record-MTPOS_MARA.
  perform bdc_field       using 'BDC_CURSOR'
                                'MARA-GROES'.
  perform bdc_field       using 'MARA-BRGEW'
                                record-BRGEW.
  if record-gewei = '' and ( salorg1 = 'X' or salorg2 = 'X'
                       or salplant = 'X' ).
    perform bdc_field       using 'MARA-GEWEI'
                                  'KG'.              " ÖØÁ¿µ¥Î»
  else.
    perform bdc_field       using 'MARA-GEWEI'
                                  record-GEWEI.      " ÖØÁ¿µ¥Î»
  endif.
  perform bdc_field       using 'MARA-NTGEW'
                                record-NTGEW.
  perform bdc_field       using 'MARA-VOLUM'
                                record-VOLUM.
  perform bdc_field       using 'MARA-VOLEH'
                                record-VOLEH.
  perform bdc_field       using 'MARA-GROES'
                                record-GROES.
condense record-EAN11 no-gaps.
if record-EAN11 <> ''.
   perform bdc_field       using 'MARA-EAN11'
                                 record-EAN11.
   perform bdc_field       using 'MARA-NUMTP'
                                 'HT'.
endif.
  perform bdc_field       using 'MARA-MAGRV'
                                record-MAGRV.
perform bdc_dynpro      using 'SAPLMGMM' '4300'.
perform bdc_field       using 'BDC_OKCODE'
                               '=ZU02'.
condense record-EAKTX no-gaps.
if record-EAKTX <> ''.
   perform bdc_field       using 'SKTEXT-SPRAS(2)'
                                 'EN'.
   perform bdc_field       using 'SKTEXT-MAKTX(2)'
                                 record-EAKTX.
endif.
perform bdc_dynpro      using 'SAPLMGMM' '4300'.
perform bdc_field       using 'BDC_OKCODE'
                               '=MAIN'.
if record-meins <> 'PAK'.
   perform bdc_field       using 'SMEINH-UMREN(05)'
                                 '1'.
   perform bdc_field       using 'SMEINH-MEINH(05)'
                                 'PAK'.
   perform bdc_field       using 'SMEINH-UMREZ(05)'
                                 '1'.
endif.
  perform bdc_dynpro      using 'SAPLMGMM' '4004'.
  perform bdc_field       using 'BDC_OKCODE'
                                '/00'.
endform.                               " GENERALDATA
*&      Form  generaldata2
      Ò»°ãÊý¾Ý 2
-->  p1        text
<--  p2        text
FORM generaldata2.
  perform bdc_dynpro      using 'SAPLMGMM' '4004'.
  perform bdc_field       using 'BDC_OKCODE'
                                '/00'.
  perform bdc_field       using 'MAKT-MAKTX'
                                record-MAKTX.
  perform bdc_field       using 'BDC_CURSOR'
                                'MARA-NORMT'.
  condense record-ferth no-gaps.
  if record-ferth <> ''.
    perform bdc_field       using 'MARA-FERTH'
                                  record-FERTH.
  endif.
  perform bdc_field       using 'MARA-NORMT'
                                record-NORMT.
  perform bdc_field       using 'MARA-WRKST'
                                record-WRKST.
perform bdc_field       using 'MARA-ZEIAR'
                               record-ZEIAR.
ENDFORM.                    " generaldata2
*&      Form  salorg1
      ÏúÊÛ×éÖ¯ 1
-->  p1        text
<--  p2        text
FORM salorg1.
  condense RECORD-SPART no-gaps.
  PERFORM BDC_DYNPRO      USING 'SAPLMGMM' '4000'.
  PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                '/00'.
  PERFORM BDC_FIELD       USING 'MAKT-MAKTX'
                                RECORD-MAKTX.     " ÎïÁÏÃèÊö
  IF K NE 'K'.
    perform bdc_field       using 'MARA-MEINS'
                                  record-MEINS.   " »ù±¾¼ÆÁ¿µ¥Î»
  ENDIF.
  perform bdc_field       using 'MARA-SPART'
                                record-SPART.     " ²úÆ·×é
  perform bdc_field       using 'MVKE-DWERK'
                                record-DWERK.     " ½»»õ¹¤³§
  PERFORM BDC_FIELD       USING 'MG03STEUER-TAXKM(01)'
                                RECORD-TAXKM.     " ÎïÁÏË°·ÖÀà
condense RECORD-VRKME no-gaps.
IF RECORD-MEINS <> RECORD-VRKME and RECORD-VRKME <> ''.
   perform bdc_field       using 'MVKE-VRKME'
                                 record-VRKME.     " ÏúÊÛµ¥Î»
   select single * from MARM where matnr = record-matnr
                 and meinh = record-vrkme.
   if SY-SUBRC NE 0.
     tmp = 'W'.
     select single * from t006 where MSEHI = record-meins.
     if t006-DIMID = 'AAAADL'.
       DIMID = ''.
     else.
       DIMID = t006-DIMID.
     endif.
     select single * from t006 where MSEHI = record-vrkme.
     if dimid <> t006-DIMID.
       PERFORM BDC_DYNPRO      USING 'SAPLMGMM' '0510'.
       PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                     '=ENTR'.
       perform bdc_field       using 'RMMZU-UMREN'
                                     record-VMREN.  "ÏúÊÛµ¥Î»×ª»»Òò×Ó
       perform bdc_field       using 'RMMZU-UMREZ'
                                     record-VMREZ.  "»ù±¾µ¥Î»×ª»»Òò×Ó
       PERFORM BDC_DYNPRO      USING 'SAPLMGMM' '4000'.
       PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                     '/00'.
     endif.
   endif.
ENDIF.
  perform bdc_dynpro      using 'SAPLMGMM' '4200'.
  perform bdc_field       using 'BDC_OKCODE'      " µ÷ÓÃË°Àà×ÓÆÁÄ»
                                '/00'.
  PERFORM BDC_DYNPRO      USING 'SAPLMGMM' '4000'.
  PERFORM BDC_FIELD       USING 'BDC_OKCODE'      " ·µ»ØÏúÊÛ×éÖ¯ 1ÆÁÄ»
                                '/00'.
ENDFORM.                                                    " salorg1
*&      Form  salorg2
      ÏúÊÛ×éÖ¯ 2
-->  p1        text
<--  p2        text
FORM salorg2.
  PERFORM BDC_DYNPRO      USING 'SAPLMGMM' '4000'.
  PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                '/00'.
  PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                'MVKE-KTGRM'.
PERFORM BDC_FIELD       USING 'MVKE-VERSG'
                               RECORD-VERSG.     " ÎïÁÏͳ¼Æ×é
  PERFORM BDC_FIELD       USING 'MVKE-KTGRM'
                                RECORD-KTGRM.     " ¿ÆÄ¿ÉèÖÃ×é
  PERFORM BDC_FIELD       USING 'MVKE-KONDM'
                                RECORD-KONDM.     " ÎïÁ϶¨¼Û×é
  perform bdc_field       using 'MVKE-MTPOS'
                                RECORD-MTPOS.     " ÏîÄ¿Àà±ð×é
PERFORM BDC_FIELD       USING 'MVKE-MVGR1'
                               RECORD-MVGR1.               " ÎïÁÏ×é 1
PERFORM BDC_FIELD       USING 'MVKE-MVGR2'
                               RECORD-MVGR2.               " ÎïÁÏ×é 2
ENDFORM.                                                    " salorg2
*&      Form  salplant
      ÏúÊÛ£ºÒ»°ã/¹¤³§Êý¾Ý
-->  p1        text
<--  p2        text
FORM salplant.
  PERFORM BDC_DYNPRO      USING 'SAPLMGMM' '4000'.
  PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                '/00'.
  select single * from marc where matnr = record-matnr
                              and werks = record-werks.
  if SY-SUBRC NE 0  OR  MARC-MTVFP = ''.
    PERFORM BDC_FIELD       USING 'MARC-MTVFP'
                                  RECORD-MTVFP.     " ¿ÉÓÃÐÔ¼ì²é
  endif.
  PERFORM BDC_FIELD       USING 'MARA-TRAGR'
                                  RECORD-TRAGR.   " ÔËÊä×é
  PERFORM BDC_FIELD       USING 'MARC-LADGR'
                                RECORD-LADGR.     " ×°ÔØ×é
  perform bdc_field       using 'MARC-XCHPF'
                                record-XCHPF.     " ÅúÁ¿¹ÜÀí
ENDFORM.                    " salplant
*&      Form  PURCHASEDATA
      ²É¹ºÊý¾Ý
-->  p1        text
<--  p2        text
form purchasedata.
  perform bdc_dynpro      using 'SAPLMGMM' '4000'.
  perform bdc_field       using 'BDC_OKCODE'
                                '/00'.
  perform bdc_field       using 'BDC_CURSOR'
                                'MARC-WEBAZ'.
  perform bdc_field       using 'MAKT-MAKTX'
                                record-MAKTX.
  IF K NE 'K'.
    perform bdc_field       using 'MARA-MEINS'
                                  record-MEINS.     " »ù±¾¼ÆÁ¿µ¥Î»
    perform bdc_field       using 'MARA-MATKL'
                                  record-MATKL.     " ÎïÁÏ×é
  ENDIF.
condense RECORD-BSTME no-gaps.
IF RECORD-MEINS <> RECORD-BSTME and RECORD-BSTME <> ''.
   perform bdc_field       using 'MARA-BSTME'
                                 record-BSTME.     " ¶©µ¥µ¥Î»
   select single * from MARM where matnr = record-matnr
                 and meinh = record-bstme.
   if SY-SUBRC NE 0 and
         ( record-vrkme <> record-bstme or tmp <> 'W' ).
     tmp = 'W'.
     select single * from t006 where MSEHI = record-meins.
     if t006-DIMID = 'AAAADL'.
       DIMID = ''.
     else.
       DIMID = t006-DIMID.
     endif.
     select single * from t006 where MSEHI = record-bstme.
     if dimid <> t006-DIMID.
       PERFORM BDC_DYNPRO      USING 'SAPLMGMM' '0510'.
       PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                     '=ENTR'.
       perform bdc_field       using 'RMMZU-UMREN'
                                     record-UMREN.  "¶©µ¥µ¥Î»×ª»»Òò×Ó
       perform bdc_field       using 'RMMZU-UMREZ'
                                     record-UMREZ.  "»ù±¾µ¥Î»×ª»»Òò×Ó
       PERFORM BDC_DYNPRO      USING 'SAPLMGMM' '4000'.
       PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                     '/00'.
     endif.
   endif.
ENDIF.
  perform bdc_field       using 'MARC-EKGRP'
                                record-EKGRP.       " ²É¹º×é
perform bdc_field       using 'MARC-WEBAZ'
                               record-WEBAZ.       " ÊÕ»õ´¦Àíʱ¼ä
endform.                               " PURCHASEDATA
*&      Form  MRP1
      text
-->  p1        text
<--  p2        text
FORM MRP1.
  perform bdc_dynpro      using 'SAPLMGMM' '4000'.
  perform bdc_field       using 'BDC_OKCODE'
                                '/00'.
perform bdc_field       using 'MAKT-MAKTX'
                               record-MAKTX.       " ÎïÁÏÃèÊö
IF K NE 'K'.
   perform bdc_field       using 'MARA-MEINS'
                                 record-MEINS.     " »ù±¾µ¥Î»
ENDIF.
perform bdc_field       using 'MARC-DISGR'
                               record-DISGR.       " MRP×é
  perform bdc_field       using 'MARC-MAABC'
                                record-MAABC.       " ABC±êʶ
  perform bdc_field       using 'MARC-DISMM'
                                record-DISMM.       " MRPÀàÐÍ
perform bdc_field       using 'MARC-FXHOR'
                               record-FXHOR.       " ¼Æ»®µÄʱ½ì
  perform bdc_field       using 'MARC-DISPO'
                                record-DISPO.       " MRP¿ØÖÆÕß
  perform bdc_field       using 'MARC-DISLS'
                                record-DISLS.       " ÅúÁ¿
perform bdc_field       using 'MARC-BSTFE'
               

Here is a sample program which creates a material with the bare minmal fields,  this will get you started.
report zrich_0003 .
data: headdata type bapimathead.
data: clientdata type bapi_mara.
data: clientdatax type bapi_marax.
data: descdata type table of BAPI_MAKT with header line.
data: return type  bapiret2 .
data: returnm type table of bapi_matreturn2 with header line.
data: xmara type mara.
parameters: p_matnr type mara-matnr.
headdata-material        = p_matnr.
headdata-ind_sector      = 'M'.
headdata-matl_type       = 'FERT'.
headdata-basic_view = 'X'.
clientdata-BASE_UOM   = 'EA'.
clientdatax-BASE_UOM   = 'X'.
clientdata-old_mat_no = 'Old Material'.
clientdatax-old_mat_no = 'X'.
clientdata-division = '00'.
clientdatax-division = 'X'.
descdata-LANGU = sy-langu.
descdata-MATL_DESC = 'This is the description'.
append descdata.
call function 'BAPI_MATERIAL_SAVEDATA'
  exporting
    headdata                   = headdata
    clientdata                 = clientdata
    clientdatax                = clientdatax
*   PLANTDATA                  =
*   PLANTDATAX                 =
*   FORECASTPARAMETERS         =
*   FORECASTPARAMETERSX        =
*   PLANNINGDATA               =
*   PLANNINGDATAX              =
*   STORAGELOCATIONDATA        =
*   STORAGELOCATIONDATAX       =
*   VALUATIONDATA              =
*   VALUATIONDATAX             =
*   WAREHOUSENUMBERDATA        =
*   WAREHOUSENUMBERDATAX       =
*   SALESDATA                  =
*   SALESDATAX                 =
*   STORAGETYPEDATA            =
*   STORAGETYPEDATAX           =
importing
   return                     = return
  tables
    MATERIALDESCRIPTION        = descdata
*   UNITSOFMEASURE             =
*   UNITSOFMEASUREX            =
*   INTERNATIONALARTNOS        =
*   MATERIALLONGTEXT           =
*   TAXCLASSIFICATIONS         =
    returnmessages             = returnm
*   PRTDATA                    =
*   PRTDATAX                   =
*   EXTENSIONIN                =
*   EXTENSIONINX               =
check sy-subrc  = 0.
Regards,
Rich Heilman

Similar Messages

  • LSMW for material master using Batch input recording method

    Dears,
    I am using Batch input recording method to upload material master data. But while selecting views , I need to scroll to select the vies lets say Plant storage loc view. While scrolling and selecting ,views are not recorded propelry . That is when I run in foreground system selects only basic data and purchasing views but the plant data views are not selected(palnt data views are selected by scrolling while recording).
    How to resolve this issue.
    Pls help
    Regards
    Kamesh

    HI,
    , I need to scroll to select the vies lets say Plant storage loc view. While scrolling and selecting ,views are not recorded propelry
    Don,t scroll use Page down button from key Bord
    like select Basis view and then press page down button from key board ,then you will get next view now select it
    Regards
    Kailas Ugale

  • Material master upload-Batch input method

    I am trying to extend sales view.When i try to upload,the system is thrwing error msg
    *     172     You have not fully maintained the tax classifications*
    The field is TAXKM,but this field not availbale in the field mapping.How to map this field & upload the tax
    Tax classification material

    Hi,
    Use Standard Batch/Direct Input method.
    Here you can use BMMH2 structure where the field TAXKM will be populated.
    Regards,
    Amol

  • LSMW--Create Material master data

    Hi,
    When I use LSMW to create material master data, I set up all step, but when I go to last step "13 Run Batch Input Session", there is error message like "Select at least one view" in moudle SAPLMGMM, screen 0070, anybody can tell me what is problem, thanks a lot.

    Hi,
    This is due to error while recording for MM01,
    Please do a Repeat recording and ensure that once the material number, industry sector and material type is entered, on the next screen you need to select all or at least a single view to create the MMR.
    Regards
    Merwyn

  • What is procedure for creating new vendor and material master data in ABAP

    What is procedure for creating new vendor and material master data in ABAP .

    see below code which is used for creation of vendor master as well as extension...
    *& Report  ZFC_VENDOR_CREATE                                           *
    REPORT  ZFC_VENDOR_CREATE  LINE-SIZE 100
                               NO STANDARD PAGE HEADING
                               MESSAGE-ID ZZ.
                         TABLES
    TABLES : SSCRFIELDS.   " Fields on selection screens
                         CONSTANTS
    DATA : C_SPLIT TYPE C VALUE '#'.  " Used for Has Separator in GUI_UPLAOD
                         TYPES
    Int'table to hold Vendor Master Data
    TYPES : BEGIN OF TY_VENDOR_MASTER,
              FLAG  TYPE C,               " Update Flag
              LIFNR TYPE LIFNR,           " Vendor Number
              BUKRS TYPE BUKRS,           " Company Code
              KTOKK TYPE KTOKK,           " Account Group
              ANRED TYPE ANRED,           " Title
              NAME1 TYPE NAME1_GP,        " Name1
              NAME2 TYPE NAME2_GP,        " Name2
              SORTL TYPE SORTL,           " Search Term 1
              SORT2 TYPE AD_SORT2UL,      " Search Term 2
              STRAS TYPE STRAS_GP,        " Street
              PSTLZ TYPE PSTLZ,           " Postal Code
              ORT01 TYPE ORT01_GP,        " City
              REGIO TYPE REGIO,           " Region
              LAND1 TYPE LAND1_GP,        " Country
              SPRAS TYPE SPRAS,           " Language
              VBUND TYPE RASSC,           " Trading Partner
              BANKS TYPE BANKS,           " Country
              BANKL TYPE BANKK,           " Bank Key
              BANKN TYPE BANKN,           " Bank Account
              BKONT TYPE BKONT,           " Bank Control Key
              BANKA TYPE BANKA,           " Name of Bank
              AKONT TYPE AKONT,           " Reconciliation Account
              FDGRV TYPE FDGRV,           " Cash Management Group
              ZTERM TYPE DZTERM,          " Payment Terms
              REPRF TYPE REPRF,           " Check Double Invoice
              ZWELS TYPE DZWELS,          " Payment Methods
              XPORE TYPE XPORE,           " Pay all items separately
            END   OF TY_VENDOR_MASTER,
    Int'table to hold Vendor Extend Data
            BEGIN OF TY_VENDOR_EXTEND,
              FLAG  TYPE C,               " Update Flag
              LIFNR     TYPE LIFNR,           " Vendor Number
              BUKRS     TYPE BUKRS,           " Company Code
              KTOKK     TYPE KTOKK,           " Account Group
              REF_LIFNR TYPE LIFNR,           " Reference Vendor Number
              REF_BUKRS TYPE BUKRS,           " Reference Company Code
              AKONT     TYPE AKONT,           " Reconciliation Account
              FDGRV     TYPE FDGRV,           " Cash Management Group
              ZTERM     TYPE DZTERM,          " Payment Terms
              REPRF     TYPE REPRF,           " Check Double Invoice
              ZWELS     TYPE DZWELS,          " Payment Methods
              XPORE TYPE XPORE,           " Pay all items separately
            END   OF TY_VENDOR_EXTEND,
    Int'table to hold Error Records Data
            BEGIN OF TY_ERROR,
              MSG(200) TYPE C,                " To hold Message
              LIFNR    TYPE LIFNR,            " Vendor Number
              BUKRS    TYPE BUKRS,            " Company Code
            END   OF TY_ERROR.
                         DATA (Simple Fields)
    DATA : W_COUNT TYPE I,               " Variable to hold count of Records
           W_SUCC_REC TYPE I,            " No. of Success Records
           W_SUCC_REC1 TYPE I,           " No. of Updated Records
           W_ERR_REC TYPE I,             " No. of Error Records
           w_noupdate_rec type i.        " No. of Records not Changed
                         INTERNAL TABLES
    Int'table to hold uploaded data from File
    DATA : IT_VENDOR_MASTER    TYPE STANDARD TABLE OF TY_VENDOR_MASTER,
           WA_IT_VENDOR_MASTER TYPE TY_VENDOR_MASTER,
           IT_VENDOR_EXTEND    TYPE STANDARD TABLE OF TY_VENDOR_EXTEND,
           WA_IT_VENDOR_EXTEND TYPE TY_VENDOR_EXTEND,
           WA_IT_BDCDATA       TYPE BDCDATA,
           IT_BDCDATA          TYPE STANDARD TABLE OF BDCDATA,
           WA_IT_MESSTAB       TYPE BDCMSGCOLL,
           IT_MESSTAB          TYPE STANDARD TABLE OF BDCMSGCOLL,
           IT_ERROR            TYPE STANDARD TABLE OF TY_ERROR,
           WA_IT_ERROR         TYPE TY_ERROR,
           it_error_fk01       type standard table of ty_error,
           wa_it_error_fk01    type ty_error,
           it_error_fk02       type standard table of ty_error,
           wa_it_error_fk02    type ty_error,
           it_succ_rec1        type standard table of ty_error,
           wa_it_succ_rec1     type ty_error,
           it_noupdate         type standard table of ty_error,
           wa_it_noupdate      type ty_error.
                         FLAGS
    DATA : FL_FLAG1 TYPE C,          " Flag to check error upload file
           FL_FLAG2 TYPE C,          " Flag to hold value
           FL_FLAG3 TYPE C,          " Flag to hold value
           FL_FLAG4 TYPE C.          " Flag to hold value
                         SELECTION-SCREEN
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    SELECTION-SCREEN : BEGIN OF LINE,
                COMMENT 1(30) TEXT-001,
                POSITION POS_LOW.
    PARAMETERS :       P_FILE(128) DEFAULT 'C:\UPLOAD.TXT' OBLIGATORY.
    SELECTION-SCREEN : END OF LINE.
    SELECTION-SCREEN : BEGIN OF LINE,
                COMMENT 1(30) TEXT-002,
                POSITION POS_LOW.
    PARAMETERS :       P_VENMAS RADIOBUTTON GROUP R1 DEFAULT 'X'.
    SELECTION-SCREEN : END OF LINE.
    SELECTION-SCREEN : BEGIN OF LINE,
                COMMENT 1(30) TEXT-003,
                POSITION POS_LOW.
    PARAMETERS :       P_VENEXT RADIOBUTTON GROUP R1.
    SELECTION-SCREEN : END OF LINE.
    SELECTION-SCREEN SKIP 2.
    SELECTION-SCREEN : BEGIN OF LINE,
                COMMENT 1(30) TEXT-004,
                POSITION POS_LOW.
    PARAMETERS :       P_MODE(1) DEFAULT 'N'.
    SELECTION-SCREEN : END OF LINE.
    SELECTION-SCREEN : BEGIN OF LINE,
                COMMENT 1(30) TEXT-005,
                POSITION POS_LOW.
    PARAMETERS :       P_GROUP(12) DEFAULT 'ZFC_VENDOR_C' OBLIGATORY.
    SELECTION-SCREEN : END OF LINE.
    SELECTION-SCREEN : BEGIN OF LINE,
                COMMENT 1(30) TEXT-016,
                POSITION POS_LOW.
    PARAMETERS :       P_GROUP1(12) DEFAULT 'ZFC_VENDOR_U' OBLIGATORY.
    SELECTION-SCREEN : END OF LINE.
    SELECTION-SCREEN END OF BLOCK B1.
                         AT SELECTION-SCREEN ON
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
    Form to get file path for upload of data
      PERFORM GET_FILE_PATH.
    AT SELECTION-SCREEN ON BLOCK B1.
    Form to Validate data specified on Selection Screen
      CHECK SSCRFIELDS-UCOMM EQ 'ONLI'.
      PERFORM VALIDATE_DATA.
                         START - OF - SELECTION
    START-OF-SELECTION.
      IF P_VENMAS = 'X'.
    Form to upload data from Presentation Server for Vendor Master
        PERFORM UPLOAD_DATA TABLES IT_VENDOR_MASTER.
        IF FL_FLAG1 NE 'X'.
          SORT IT_VENDOR_MASTER BY LIFNR BUKRS KTOKK.
          DELETE IT_VENDOR_MASTER WHERE LIFNR = ' '
                                  AND   BUKRS = ' '
                                  AND   KTOKK = ' '.
    Form to process data for Vendor Master
          PERFORM INSERT_VENDOR_MASTER_DATA.
        ENDIF.
      ELSEIF P_VENEXT = 'X'.
    Form to upload data from Presentation Server for Vendor Extend
        PERFORM UPLOAD_DATA TABLES IT_VENDOR_EXTEND.
        IF FL_FLAG1 NE 'X'.
          SORT IT_VENDOR_EXTEND BY LIFNR BUKRS KTOKK.
          DELETE IT_VENDOR_EXTEND WHERE LIFNR = ' '
                                  AND   BUKRS = ' '
                                  AND   KTOKK = ' '.
    Form to process data for Vendor Master
          PERFORM CHK_AND_INS_VENDOR_EXTEND_DATA.
        ENDIF.
      ENDIF.
                         END - OF - SELECTION
    END-OF-SELECTION.
      IF FL_FLAG1 NE 'X'.
        FORMAT COLOR 7.
        WRITE:/2 TEXT-O01.           " Total Number of records read :
        FORMAT COLOR OFF.
        WRITE:40 W_COUNT.
        FORMAT COLOR 7.
        WRITE:/2 TEXT-O02.           " Total Number of Success records :
        FORMAT COLOR OFF.
        WRITE:40 W_SUCC_REC.
        FORMAT COLOR 7.
        WRITE:/2 TEXT-O07.           " Total Number of Updated records :
        FORMAT COLOR OFF.
        WRITE:40 W_SUCC_REC1.
        FORMAT COLOR 7.
        WRITE:/2 TEXT-O08.           " Total Number of Unchanged records :
        FORMAT COLOR OFF.
        WRITE:40 W_noupdate_REC.
        FORMAT COLOR 7.
        WRITE:/2 TEXT-O03.           " Total Number of Error records :
        FORMAT COLOR OFF.
        WRITE:40 W_ERR_REC.
        if not it_succ_rec1 is initial.
          skip 1.
          perform display_changed_report.
        endif.
        if not it_noupdate is initial.
          skip 1.
          perform display_nochange_report.
        endif.
        IF NOT IT_ERROR IS INITIAL.
          SKIP 3.
    Form to display error data
          PERFORM DISPLAY_ERROR_REPORT.
        ENDIF.
        IF FL_FLAG2 = 'X'.
          SKIP 2.
          FORMAT COLOR 4.
          WRITE:/2 TEXT-O04.        " BDC Session Name for Creation (FK01) :
          FORMAT COLOR OFF.
          WRITE:40 P_GROUP.
          perform display_error_report_fk01.
        ENDIF.
        IF FL_FLAG3 = 'X'.
          SKIP 2.
          FORMAT COLOR 4.
          WRITE:/2 TEXT-O09.        " BDC Session Name for Updation (FK02) :
          FORMAT COLOR OFF.
          WRITE:40 P_GROUP1.
          perform display_error_report_fk02.
        ENDIF.
      ENDIF.
    *&      Form  GET_FILE_PATH
    This form is used to get the specified path for uploading of data from
    flat file with the help of F4 function key
    FORM GET_FILE_PATH .
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          PROGRAM_NAME  = SYST-CPROG
          DYNPRO_NUMBER = SYST-DYNNR
          FIELD_NAME    = ' '
        IMPORTING
          FILE_NAME     = P_FILE.
    ENDFORM.                    " GET_FILE_PATH
    *&      Form  VALIDATE_DATA
    This form is used to validate the data given by user on the Selection
    Screen and the appropriate message is been displayed when an wrong
    entry is inputted
    FORM VALIDATE_DATA .
      IF SY-BATCH EQ 'X'.
        CLEAR SSCRFIELDS-UCOMM.
        MESSAGE E001(ZZ) WITH TEXT-011.
        " Excel file not to be used in Batch Mode
      ENDIF.
      IF P_MODE NE 'A' AND P_MODE NE 'N' AND P_MODE NE 'E'.
        MESSAGE E001(ZZ) WITH TEXT-012.
        " Session Mode should be either A or N or E
      ENDIF.
    ENDFORM.                    " VALIDATE_DATA
    *&      Form  UPLOAD_DATA
    This form is used to upload data from Presentation Server for either
    Vendor Master or Vendor Extend
    FORM UPLOAD_DATA TABLES P_IT_VENDOR.
      DATA : L_FILENAME TYPE STRING,
             L_FILETYPE TYPE CHAR10 VALUE 'ASC',
             L_HEADER_LENGTH TYPE I VALUE 0,
             L_READ_BY_LINE TYPE CHAR01 VALUE 'X'.
      MOVE P_FILE TO L_FILENAME.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          FILENAME                = L_FILENAME
          FILETYPE                = L_FILETYPE
          HEADER_LENGTH           = L_HEADER_LENGTH
          READ_BY_LINE            = L_READ_BY_LINE
          HAS_FIELD_SEPARATOR     = C_SPLIT
        TABLES
          DATA_TAB                = P_IT_VENDOR
        EXCEPTIONS
          FILE_OPEN_ERROR         = 1
          FILE_READ_ERROR         = 2
          NO_BATCH                = 3
          GUI_REFUSE_FILETRANSFER = 4
          INVALID_TYPE            = 5
          NO_AUTHORITY            = 6
          UNKNOWN_ERROR           = 7
          BAD_DATA_FORMAT         = 8
          HEADER_NOT_ALLOWED      = 9
          SEPARATOR_NOT_ALLOWED   = 10
          HEADER_TOO_LONG         = 11
          UNKNOWN_DP_ERROR        = 12
          ACCESS_DENIED           = 13
          DP_OUT_OF_MEMORY        = 14
          DISK_FULL               = 15
          DP_TIMEOUT              = 16
          OTHERS                  = 17.
      IF SY-SUBRC <> 0.
       MESSAGE I001(ZZ) WITH TEXT-006 L_FILENAME.
    MESSAGE ID SY-MSGID TYPE 'I' NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        FL_FLAG1 = 'X'.
      ELSEIF P_IT_VENDOR[] IS INITIAL.
        MESSAGE I001(ZZ) WITH TEXT-014.   " Uploaded File contains no data
        FL_FLAG1 = 'X'.
      ENDIF.
    ENDFORM.                    " UPLOAD_DATA
    *&      Form  INSERT_VENDOR_MASTER_DATA
    This form is used to process BDC data for Vendor Master
    FORM INSERT_VENDOR_MASTER_DATA .
      DATA : L_LIFNR TYPE LIFNR.
      CLEAR : L_LIFNR.
      sort it_vendor_master by flag.
      LOOP AT IT_VENDOR_MASTER INTO WA_IT_VENDOR_MASTER.
        W_COUNT = W_COUNT + 1.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            INPUT  = WA_IT_VENDOR_MASTER-LIFNR
          IMPORTING
            OUTPUT = WA_IT_VENDOR_MASTER-LIFNR.
        if wa_it_vendor_master-flag = 'A'.
        SELECT SINGLE LIFNR
               FROM LFB1
               INTO L_LIFNR
               WHERE LIFNR = WA_IT_VENDOR_MASTER-LIFNR
               AND   BUKRS = WA_IT_VENDOR_MASTER-BUKRS.
        IF SY-SUBRC EQ 0.
          WA_IT_ERROR-LIFNR = WA_IT_VENDOR_MASTER-LIFNR.
          WA_IT_ERROR-BUKRS = WA_IT_VENDOR_MASTER-BUKRS.
          WA_IT_ERROR-MSG   = TEXT-015.
          APPEND WA_IT_ERROR TO IT_ERROR.
          W_ERR_REC = W_ERR_REC + 1.
          CLEAR : WA_IT_ERROR, L_LIFNR.
        ELSE.
          REFRESH IT_BDCDATA.
          CLEAR IT_BDCDATA.
          PERFORM POPULATE_BDC_DATA_VEN_MASTER.
          PERFORM CALL_TRANSACTION.
        ENDIF.
        CLEAR : WA_IT_VENDOR_MASTER.
        elseif wa_it_vendor_master-flag = 'C'.
          IF FL_FLAG2 = 'X' and fl_flag4 ne 'X'.
            PERFORM CLOSE_BDC_SESSION.
            fl_flag4 = 'X'.
          ENDIF.
          REFRESH IT_BDCDATA.
          CLEAR IT_BDCDATA.
          PERFORM POPULATE_BDC_DATA_VEN_MASTER.
          PERFORM CALL_TRANSACTION_FK02.
          CLEAR : WA_IT_VENDOR_MASTER.
        elseif wa_it_vendor_master-flag = 'N'.
          WA_IT_noupdate-LIFNR = WA_IT_VENDOR_MASTER-LIFNR.
          WA_IT_noupdate-BUKRS = WA_IT_VENDOR_MASTER-BUKRS.
          WA_IT_noupdate-MSG   = TEXT-018.
          APPEND WA_IT_noupdate TO IT_noupdate.
          W_noupdate_REC = W_noupdate_REC + 1.
          CLEAR : WA_IT_noupdate, WA_IT_VENDOR_MASTER.
        endif.
      ENDLOOP.
      IF FL_FLAG3 = 'X'.
        PERFORM CLOSE_BDC_SESSION.
      ENDIF.
    ENDFORM.                    " INSERT_VENDOR_MASTER_DATA
    *&      Form  POPULATE_BDC_DATA_VEN_MASTER
    This form is used to populate BDC data of Vendor Master
    FORM POPULATE_BDC_DATA_VEN_MASTER .
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          INPUT  = WA_IT_VENDOR_MASTER-ZTERM
        IMPORTING
          OUTPUT = WA_IT_VENDOR_MASTER-ZTERM.
      IF WA_IT_VENDOR_MASTER-REPRF = 'Y'.
        WA_IT_VENDOR_MASTER-REPRF = 'X'.
      ENDIF.
      IF WA_IT_VENDOR_MASTER-XPORE = 'Y'.
        WA_IT_VENDOR_MASTER-XPORE = 'X'.
      ENDIF.
      if wa_it_vendor_master-flag = 'A'.
      PERFORM :BDC_DYNPRO USING 'SAPMF02K' '0105',
               BDC_FIELD  USING 'RF02K-LIFNR' WA_IT_VENDOR_MASTER-LIFNR,
               BDC_FIELD  USING 'RF02K-BUKRS' WA_IT_VENDOR_MASTER-BUKRS,
               BDC_FIELD  USING 'RF02K-KTOKK' WA_IT_VENDOR_MASTER-KTOKK,
               BDC_FIELD  USING 'BDC_OKCODE'  '/00'.
      elseif wa_it_vendor_master-flag = 'C'.
      PERFORM :BDC_DYNPRO USING 'SAPMF02K' '0106',
               BDC_FIELD  USING 'RF02K-LIFNR' WA_IT_VENDOR_MASTER-LIFNR,
               BDC_FIELD  USING 'RF02K-BUKRS' WA_IT_VENDOR_MASTER-BUKRS,
               BDC_FIELD  USING 'BDC_OKCODE'  '=MALL',
               BDC_DYNPRO USING 'SAPMF02K' '0106',
               BDC_FIELD  USING 'RF02K-D0110' 'X',
               BDC_FIELD  USING 'RF02K-D0120' 'X',
               BDC_FIELD  USING 'RF02K-D0130' 'X',
               BDC_FIELD  USING 'RF02K-D0210' 'X',
               BDC_FIELD  USING 'RF02K-D0215' 'X',
               BDC_FIELD  USING 'RF02K-D0220' 'X',
               BDC_FIELD  USING 'BDC_OKCODE'  '/00'.
      endif.
      perform :BDC_DYNPRO USING 'SAPMF02K' '0110',
               BDC_FIELD  USING 'LFA1-ANRED'  WA_IT_VENDOR_MASTER-ANRED,
               BDC_FIELD  USING 'LFA1-NAME1'  WA_IT_VENDOR_MASTER-NAME1,
               BDC_FIELD  USING 'LFA1-NAME2'  WA_IT_VENDOR_MASTER-NAME2,
               BDC_FIELD  USING 'LFA1-SORTL'  WA_IT_VENDOR_MASTER-SORTL,
               BDC_FIELD  USING 'LFA1-STRAS'  WA_IT_VENDOR_MASTER-STRAS,
               BDC_FIELD  USING 'LFA1-ORT01'  WA_IT_VENDOR_MASTER-ORT01,
               BDC_FIELD  USING 'LFA1-PSTLZ'  WA_IT_VENDOR_MASTER-PSTLZ,
               BDC_FIELD  USING 'LFA1-LAND1'  WA_IT_VENDOR_MASTER-LAND1,
               BDC_FIELD  USING 'LFA1-REGIO'  WA_IT_VENDOR_MASTER-REGIO,
               BDC_FIELD  USING 'LFA1-SPRAS'  WA_IT_VENDOR_MASTER-SPRAS,
               BDC_FIELD  USING 'BDC_OKCODE'  '/00',
               BDC_DYNPRO USING 'SAPMF02K' '0120',
               BDC_FIELD  USING 'LFA1-VBUND'  WA_IT_VENDOR_MASTER-VBUND,
               BDC_FIELD  USING 'BDC_OKCODE'  '/00',
               BDC_DYNPRO USING 'SAPMF02K' '0130',
               BDC_FIELD  USING 'LFBK-BANKS(01)'  WA_IT_VENDOR_MASTER-BANKS,
               BDC_FIELD  USING 'LFBK-BANKL(01)'  WA_IT_VENDOR_MASTER-BANKL,
               BDC_FIELD  USING 'LFBK-BANKN(01)'  WA_IT_VENDOR_MASTER-BANKN,
               BDC_FIELD  USING 'BDC_OKCODE'  '=BANK',
               BDC_DYNPRO USING 'SAPLBANK' '0100',
               BDC_FIELD  USING 'BNKA-BANKA'  WA_IT_VENDOR_MASTER-BANKA,
               BDC_FIELD  USING 'BDC_OKCODE'  '=ENTR',
               BDC_DYNPRO USING 'SAPMF02K' '0130',
               BDC_FIELD  USING 'BDC_OKCODE'  '=ENTR',
               BDC_DYNPRO USING 'SAPMF02K' '0210',
               BDC_FIELD  USING 'LFB1-AKONT'  WA_IT_VENDOR_MASTER-AKONT,
               BDC_FIELD  USING 'LFB1-FDGRV'  WA_IT_VENDOR_MASTER-FDGRV,
               BDC_FIELD  USING 'BDC_OKCODE'  '=/00',
               BDC_DYNPRO USING 'SAPMF02K' '0215',
               BDC_FIELD  USING 'LFB1-ZTERM'  WA_IT_VENDOR_MASTER-ZTERM,
               BDC_FIELD  USING 'LFB1-REPRF'  WA_IT_VENDOR_MASTER-REPRF,
               BDC_FIELD  USING 'LFB1-ZWELS'  WA_IT_VENDOR_MASTER-ZWELS,
               BDC_FIELD  USING 'LFB1-XPORE'  WA_IT_VENDOR_MASTER-XPORE,
               BDC_FIELD  USING 'BDC_OKCODE'  '=UPDA'.
    ENDFORM.                    " POPULATE_BDC_DATA_VEN_MASTER
    *&      Form  BDC_DYNPRO
    This form is used to move data to BDCDATA int'table
    FORM BDC_DYNPRO  USING PROGRAM TYPE BDC_PROG
                           DYNPRO  TYPE BDC_DYNR.
      CLEAR WA_IT_BDCDATA.
      WA_IT_BDCDATA-PROGRAM  = PROGRAM.
      WA_IT_BDCDATA-DYNPRO   = DYNPRO.
      WA_IT_BDCDATA-DYNBEGIN = 'X'.
      APPEND WA_IT_BDCDATA TO IT_BDCDATA.
    ENDFORM.                    " BDC_DYNPRO
    *&      Form  BDC_FIELD
    This form is used to move data to BDCDATA int'table
    FORM BDC_FIELD  USING FNAM TYPE ANY
                          FVAL TYPE ANY.
      CLEAR WA_IT_BDCDATA.
      WA_IT_BDCDATA-FNAM = FNAM.
      WA_IT_BDCDATA-FVAL = FVAL.
      APPEND WA_IT_BDCDATA TO IT_BDCDATA.
    ENDFORM.                    " BDC_FIELD
    *&      Form  CALL_TRANSACTION
    This form is used to Call FK01 for processing of data either for
    Vendor Master or Vendor Extend. The error records are inserted to
    Session which can be processed using SM35
    FORM CALL_TRANSACTION .
      DATA : L_OPTION TYPE CTU_PARAMS,
             L_SUBRC TYPE SYSUBRC.
      REFRESH IT_MESSTAB.
      CLEAR IT_MESSTAB.
      L_OPTION-DEFSIZE = 'X'.
      L_OPTION-DISMODE = P_MODE.
      L_OPTION-UPDMODE = 'S'.
      CALL TRANSACTION 'FK01'
           USING IT_BDCDATA
           MESSAGES INTO IT_MESSTAB
           OPTIONS FROM L_OPTION.
      L_SUBRC = SY-SUBRC.
      IF L_SUBRC = 0.
        W_SUCC_REC = W_SUCC_REC + 1.
      ELSE.
        IF FL_FLAG2 NE 'X'.
          PERFORM OPEN_BDC_SESSION.
          FL_FLAG2 = 'X'.
        ENDIF.
        PERFORM BDC_INSERT.
        W_ERR_REC = W_ERR_REC + 1.
        PERFORM ERROR_RECORD_DATA.
      ENDIF.
    ENDFORM.                    " CALL_TRANSACTION
    *&      Form  OPEN_BDC_SESSION
    Form used to open session for Error out Records
    FORM OPEN_BDC_SESSION .
      DATA : L_USERID TYPE APQ_MAPN,      " Variable to hold user-id
             L_GROUP TYPE APQ_GRPN.       " Variable to hold value
      MOVE P_GROUP TO L_GROUP.
      MOVE SY-UNAME TO L_USERID.
      CALL FUNCTION 'BDC_OPEN_GROUP'
        EXPORTING
          CLIENT              = SY-MANDT
          GROUP               = L_GROUP
          KEEP                = SPACE
          USER                = L_USERID
        EXCEPTIONS
          CLIENT_INVALID      = 1
          DESTINATION_INVALID = 2
          GROUP_INVALID       = 3
          GROUP_IS_LOCKED     = 4
          HOLDDATE_INVALID    = 5
          INTERNAL_ERROR      = 6
          QUEUE_ERROR         = 7
          RUNNING             = 8
          SYSTEM_LOCK_ERROR   = 9
          USER_INVALID        = 10
          OTHERS              = 11.
      IF SY-SUBRC <> 0.
        WRITE:/ TEXT-008.              " Unable to open BDC Session
      ENDIF.
    ENDFORM.                    " OPEN_BDC_SESSION
    *&      Form  BDC_INSERT
    This form is used to insert error records to a Session method
    FORM BDC_INSERT .
      CALL FUNCTION 'BDC_INSERT'
        EXPORTING
          TCODE            = 'FK01'
        TABLES
          DYNPROTAB        = IT_BDCDATA
        EXCEPTIONS
          INTERNAL_ERROR   = 1
          NOT_OPEN         = 2
          QUEUE_ERROR      = 3
          TCODE_INVALID    = 4
          PRINTING_INVALID = 5
          POSTING_INVALID  = 6
          OTHERS           = 7.
      IF SY-SUBRC <> 0.
        WRITE:/ TEXT-009.             " Unable to Insert Data to BDC Session
      ENDIF.
    ENDFORM.                    " BDC_INSERT
    *&      Form  ERROR_RECORD_DATA
    This form is used to process the messages for the error records which
    will be displayed on the output report
    FORM ERROR_RECORD_DATA .
      DATA : L_LINES TYPE I,
             L_MSG(200) TYPE C.
      DESCRIBE TABLE IT_MESSTAB LINES L_LINES.
      READ TABLE IT_MESSTAB INTO WA_IT_MESSTAB INDEX L_LINES.
      IF SY-SUBRC = 0.
        CLEAR L_MSG.
        CALL FUNCTION 'FORMAT_MESSAGE'
          EXPORTING
            ID        = WA_IT_MESSTAB-MSGID
            LANG      = SY-LANGU
            NO        = WA_IT_MESSTAB-MSGNR
            V1        = WA_IT_MESSTAB-MSGV1
            V2        = WA_IT_MESSTAB-MSGV2
            V3        = WA_IT_MESSTAB-MSGV3
            V4        = WA_IT_MESSTAB-MSGV4
          IMPORTING
            MSG       = L_MSG
          EXCEPTIONS
            NOT_FOUND = 1
            OTHERS    = 2.
        IF SY-SUBRC = 0.
          WA_IT_ERROR_fk01-MSG = L_MSG.
        ENDIF.
        IF P_VENMAS = 'X'.
          WA_IT_ERROR_fk01-LIFNR = WA_IT_VENDOR_MASTER-LIFNR.
          WA_IT_ERROR_fk01-BUKRS = WA_IT_VENDOR_MASTER-BUKRS.
        ELSEIF P_VENEXT = 'X'.
          WA_IT_ERROR_fk01-LIFNR = WA_IT_VENDOR_EXTEND-LIFNR.
          WA_IT_ERROR_fk01-BUKRS = WA_IT_VENDOR_EXTEND-BUKRS.
        ENDIF.
        APPEND WA_IT_ERROR_fk01 TO IT_ERROR_fk01.
        CLEAR WA_IT_ERROR_fk01.
      ENDIF.
    ENDFORM.                    " ERROR_RECORD_DATA
    *&      Form  CLOSE_BDC_SESSION
    Form used to close session of the Error Records
    FORM CLOSE_BDC_SESSION .
      CALL FUNCTION 'BDC_CLOSE_GROUP'
        EXCEPTIONS
          NOT_OPEN    = 1
          QUEUE_ERROR = 2
          OTHERS      = 3.
      IF SY-SUBRC <> 0.
        WRITE:/ TEXT-010.             " Unable to Close BDC Session
      ENDIF.
    ENDFORM.                    " CLOSE_BDC_SESSION
    *&      Form  CHK_AND_INS_VENDOR_EXTEND_DATA
    This form is used to process BDC data for Vendor Extend
    FORM CHK_AND_INS_VENDOR_EXTEND_DATA .
      DATA : L_LIFNR TYPE LIFNR.
      CLEAR : L_LIFNR, fl_flag4.
      sort it_vendor_extend by flag.
      LOOP AT IT_VENDOR_EXTEND INTO WA_IT_VENDOR_EXTEND.
        W_COUNT = W_COUNT + 1.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            INPUT  = WA_IT_VENDOR_EXTEND-REF_LIFNR
          IMPORTING
            OUTPUT = WA_IT_VENDOR_EXTEND-REF_LIFNR.
        if wa_it_vendor_extend-flag = 'A'.
        SELECT SINGLE LIFNR
               FROM LFB1
               INTO L_LIFNR
               WHERE LIFNR = WA_IT_VENDOR_EXTEND-REF_LIFNR
               AND   BUKRS = WA_IT_VENDOR_EXTEND-REF_BUKRS.
        IF SY-SUBRC NE 0.
          WA_IT_ERROR-LIFNR = WA_IT_VENDOR_EXTEND-REF_LIFNR.
          WA_IT_ERROR-BUKRS = WA_IT_VENDOR_EXTEND-REF_BUKRS.
          WA_IT_ERROR-MSG   = TEXT-007.
          APPEND WA_IT_ERROR TO IT_ERROR.
          W_ERR_REC = W_ERR_REC + 1.
          CLEAR : WA_IT_ERROR, L_LIFNR.
        ELSE.
          CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
            EXPORTING
              INPUT  = WA_IT_VENDOR_EXTEND-LIFNR
            IMPORTING
              OUTPUT = WA_IT_VENDOR_EXTEND-LIFNR.
          SELECT SINGLE LIFNR
                 FROM LFB1
                 INTO L_LIFNR
                 WHERE LIFNR = WA_IT_VENDOR_EXTEND-LIFNR
                 AND   BUKRS = WA_IT_VENDOR_EXTEND-BUKRS.
          IF SY-SUBRC EQ 0.
            WA_IT_ERROR-LIFNR = WA_IT_VENDOR_EXTEND-LIFNR.
            WA_IT_ERROR-BUKRS = WA_IT_VENDOR_EXTEND-BUKRS.
            WA_IT_ERROR-MSG   = TEXT-015.
            APPEND WA_IT_ERROR TO IT_ERROR.
            W_ERR_REC = W_ERR_REC + 1.
            CLEAR : WA_IT_ERROR, L_LIFNR.
          ELSE.
            REFRESH IT_BDCDATA.
            CLEAR IT_BDCDATA.
            PERFORM POPULATE_BDC_DATA_VEN_EXTEND.
            PERFORM CALL_TRANSACTION.
          ENDIF.
        ENDIF.
        CLEAR : WA_IT_VENDOR_EXTEND.
        elseif wa_it_vendor_extend-flag = 'C'.
          IF FL_FLAG2 = 'X' and fl_flag4 ne 'X'.
            PERFORM CLOSE_BDC_SESSION.
            fl_flag4 = 'X'.
          ENDIF.
          REFRESH IT_BDCDATA.
          CLEAR IT_BDCDATA.
          PERFORM POPULATE_BDC_DATA_VEN_extend.
          PERFORM CALL_TRANSACTION_FK02.
           CLEAR : WA_IT_VENDOR_EXTEND.
        elseif wa_it_vendor_extend-flag = 'N'.
          WA_IT_noupdate-LIFNR = WA_IT_VENDOR_extend-LIFNR.
          WA_IT_noupdate-BUKRS = WA_IT_VENDOR_extend-BUKRS.
          WA_IT_noupdate-MSG   = TEXT-019.
          APPEND WA_IT_noupdate TO IT_noupdate.
          W_noupdate_REC = W_noupdate_REC + 1.
          CLEAR : WA_IT_noupdate, WA_IT_VENDOR_EXTEND.
        endif.
      ENDLOOP.
      IF FL_FLAG2 = 'X'.
        PERFORM CLOSE_BDC_SESSION.
      ENDIF.
      if fl_flag3 = 'X'.
        PERFORM CLOSE_BDC_SESSION.
      ENDIF.
    ENDFORM.                    " CHK_AND_INS_VENDOR_EXTEND_DATA
    *&      Form  POPULATE_BDC_DATA_VEN_EXTEND
    This form is used to populate BDC data of Vendor Extend
    FORM POPULATE_BDC_DATA_VEN_EXTEND .
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          INPUT  = WA_IT_VENDOR_EXTEND-ZTERM
        IMPORTING
          OUTPUT = WA_IT_VENDOR_EXTEND-ZTERM.
      IF WA_IT_VENDOR_EXTEND-REPRF = 'Y'.
        WA_IT_VENDOR_EXTEND-REPRF = 'X'.
      ENDIF.
      IF WA_IT_VENDOR_extend-XPORE = 'Y'.
        WA_IT_VENDOR_extend-XPORE = 'X'.
      ENDIF.
      if wa_it_vendor_extend-flag = 'A'.
      PERFORM :BDC_DYNPRO USING 'SAPMF02K' '0105',
               BDC_FIELD  USING 'RF02K-LIFNR' WA_IT_VENDOR_EXTEND-LIFNR,
               BDC_FIELD  USING 'RF02K-BUKRS' WA_IT_VENDOR_EXTEND-BUKRS,
               BDC_FIELD  USING 'RF02K-KTOKK' WA_IT_VENDOR_EXTEND-KTOKK,
               BDC_FIELD  USING 'RF02K-REF_LIFNR'
                                          WA_IT_VENDOR_EXTEND-REF_LIFNR,
               BDC_FIELD  USING 'RF02K-REF_BUKRS'
                                          WA_IT_VENDOR_EXTEND-REF_BUKRS,
               BDC_FIELD  USING 'BDC_OKCODE'  '/00'.
      elseif wa_it_vendor_extend-flag = 'C'.
      PERFORM :BDC_DYNPRO USING 'SAPMF02K' '0106',
               BDC_FIELD  USING 'RF02K-LIFNR' WA_IT_VENDOR_extend-LIFNR,
               BDC_FIELD  USING 'RF02K-BUKRS' WA_IT_VENDOR_extend-BUKRS,
               BDC_FIELD  USING 'RF02K-D0210' 'X',
               BDC_FIELD  USING 'RF02K-D0215' 'X',
               BDC_FIELD  USING 'BDC_OKCODE'  '/00'.
      endif.
      perform :BDC_DYNPRO USING 'SAPMF02K' '0210',
               BDC_FIELD  USING 'LFB1-AKONT'  WA_IT_VENDOR_EXTEND-AKONT,
               BDC_FIELD  USING 'LFB1-FDGRV'  WA_IT_VENDOR_EXTEND-FDGRV,
               BDC_FIELD  USING 'BDC_OKCODE'  '=/00',
               BDC_DYNPRO USING 'SAPMF02K' '0215',
               BDC_FIELD  USING 'LFB1-ZTERM'  WA_IT_VENDOR_EXTEND-ZTERM,
               BDC_FIELD  USING 'LFB1-REPRF'  WA_IT_VENDOR_EXTEND-REPRF,
               BDC_FIELD  USING 'LFB1-ZWELS'  WA_IT_VENDOR_EXTEND-ZWELS,
               BDC_FIELD  USING 'LFB1-XPORE'  WA_IT_VENDOR_extend-XPORE,
               BDC_FIELD  USING 'BDC_OKCODE'  '=UPDA'.
    ENDFORM.                    " POPULATE_BDC_DATA_VEN_EXTEND
    *&      Form  DISPLAY_ERROR_REPORT
    This form is used to display the error records on the output screen
    FORM DISPLAY_ERROR_REPORT .
      IF P_VENMAS = 'X'.
        WRITE:/ TEXT-O05.            " Error List for Vendor Master
      ELSEIF P_VENEXT = 'X'.
        WRITE:/ TEXT-O06.            " Error List for Vendor Master Extended
      ENDIF.
      WRITE:/ SY-ULINE(100).
      FORMAT COLOR 1.
      WRITE:/1   SY-VLINE,
             2   TEXT-H01,              " Vendor Number
             17  SY-VLINE,
             18  TEXT-H02,              " Company Code
             31  SY-VLINE,
             32  TEXT-H03,              " Error Message
             100 SY-VLINE.
      FORMAT COLOR OFF.
      WRITE:/ SY-ULINE(100).
      LOOP AT IT_ERROR INTO WA_IT_ERROR.
        FORMAT COLOR 2.
        WRITE:/1   SY-VLINE,
               2   WA_IT_ERROR-LIFNR,
               17  SY-VLINE,
               18  WA_IT_ERROR-BUKRS,
               31  SY-VLINE,
               32  WA_IT_ERROR-MSG,
               100 SY-VLINE.
        CLEAR : WA_IT_ERROR.
        FORMAT COLOR OFF.
      ENDLOOP.
      WRITE:/ SY-ULINE(100).
    ENDFORM.                    " DISPLAY_ERROR_REPORT
    *&      Form  CALL_TRANSACTION_FK02
    Form used to Call Transaction FK02
    form CALL_TRANSACTION_FK02 .
      DATA : L_OPTION TYPE CTU_PARAMS,
             L_SUBRC TYPE SYSUBRC.
      REFRESH IT_MESSTAB.
      CLEAR IT_MESSTAB.
      L_OPTION-DEFSIZE = 'X'.
      L_OPTION-DISMODE = P_MODE.
      L_OPTION-UPDMODE = 'S'.
      CALL TRANSACTION 'FK02'
           USING IT_BDCDATA
           MESSAGES INTO IT_MESSTAB
           OPTIONS FROM L_OPTION.
      L_SUBRC = SY-SUBRC.
      IF L_SUBRC = 0.
        W_SUCC_REC1 = W_SUCC_REC1 + 1.
        WA_IT_succ_rec1-MSG = Text-017.
        IF P_VENMAS = 'X'.
          WA_IT_succ_rec1-LIFNR = WA_IT_VENDOR_MASTER-LIFNR.
          WA_IT_succ_rec1-BUKRS = WA_IT_VENDOR_MASTER-BUKRS.
        ELSEIF P_VENEXT = 'X'.
          WA_IT_succ_rec1-LIFNR = WA_IT_VENDOR_EXTEND-LIFNR.
          WA_IT_succ_rec1-BUKRS = WA_IT_VENDOR_EXTEND-BUKRS.
        ENDIF.
        APPEND WA_IT_succ_rec1 TO IT_succ_rec1.
      ELSE.
        IF FL_FLAG3 NE 'X'.
          PERFORM OPEN_BDC_SESSION_fk02.
          FL_FLAG3 = 'X'.
        ENDIF.
        PERFORM BDC_INSERT_fk02.
        W_ERR_REC = W_ERR_REC + 1.
        PERFORM ERROR_RECORD_DATA1.
      ENDIF.
    endform.                    " CALL_TRANSACTION_FK02
    *&      Form  OPEN_BDC_SESSION_fk02
    Form used to Open session for FK02
    form OPEN_BDC_SESSION_fk02 .
      DATA : L_USERID TYPE APQ_MAPN,      " Variable to hold user-id
             L_GROUP TYPE APQ_GRPN.       " Variable to hold value
      MOVE P_GROUP1 TO L_GROUP.
      MOVE SY-UNAME TO L_USERID.
      CALL FUNCTION 'BDC_OPEN_GROUP'
        EXPORTING
          CLIENT              = SY-MANDT
          GROUP               = L_GROUP
          KEEP                = SPACE
          USER                = L_USERID
        EXCEPTIONS
          CLIENT_INVALID      = 1
          DESTINATION_INVALID = 2
          GROUP_INVALID       = 3
          GROUP_IS_LOCKED     = 4
          HOLDDATE_INVALID    = 5
          INTERNAL_ERROR      = 6
          QUEUE_ERROR         = 7
          RUNNING             = 8
          SYSTEM_LOCK_ERROR   = 9
          USER_INVALID        = 10
          OTHERS              = 11.
      IF SY-SUBRC <> 0.
        WRITE:/ TEXT-008.              " Unable to open BDC Session
      ENDIF.
    endform.                    " OPEN_BDC_SESSION_fk02
    *&      Form  BDC_INSERT_fk02
    Form used to insert data into BDC session using FK02
    form BDC_INSERT_fk02 .
      CALL FUNCTION 'BDC_INSERT'
        EXPORTING
          TCODE            = 'FK02'
        TABLES
          DYNPROTAB        = IT_BDCDATA
        EXCEPTIONS
          INTERNAL_ERROR   = 1
          NOT_OPEN         = 2
          QUEUE_ERROR      = 3
          TCODE_INVALID    = 4
          PRINTING_INVALID = 5
          POSTING_INVALID  = 6
          OTHERS           = 7.
      IF SY-SUBRC <> 0.
        WRITE:/ TEXT-009.             " Unable to Insert Data to BDC Session
      ENDIF.
    endform.                    " BDC_INSERT_fk02
    *&      Form  display_changed_report
    Form to display Updated Vendor data
    form display_changed_report .
      IF P_VENMAS = 'X'.
        WRITE:/ TEXT-O10.          " Updated List for Vendor Master
      ELSEIF P_VENEXT = 'X'.
        WRITE:/ TEXT-O11.          " Updated List for Vendor Master Extended
      ENDIF.
      WRITE:/ SY-ULINE(100).
      FORMAT COLOR 1.
      WRITE:/1   SY-VLINE,
             2   TEXT-H01,              " Vendor Number
             17  SY-VLINE,
             18  TEXT-H02,              " Company Code
             31  SY-VLINE,
             32  TEXT-H04,              " Message
             100 SY-VLINE.
      FORMAT COLOR OFF.
      WRITE:/ SY-ULINE(100).
      LOOP AT IT_succ_rec1 INTO WA_IT_succ_rec1.
        FORMAT COLOR 2.
        WRITE:/1   SY-VLINE,
               2   WA_IT_succ_rec1-LIFNR,
               17  SY-VLINE,
               18  WA_IT_succ_rec1-BUKRS,
               31  SY-VLINE,
               32  WA_IT_succ_rec1-MSG,
               100 SY-VLINE.
        CLEAR : WA_IT_succ_rec1.
        FORMAT COLOR OFF.
      ENDLOOP.
      WRITE:/ SY-ULINE(100).
    endform.                    " display_changed_report
    *&      Form  display_nochange_report
    Form to display No Changed data for Vendors
    form display_nochange_report .
      IF P_VENMAS = 'X'.
        WRITE:/ TEXT-O12.       " No Changes List for Vendor Master
      ELSEIF P_VENEXT = 'X'.
        WRITE:/ TEXT-O13.       " No Changes List for Vendor Master Extended
      ENDIF.
      WRITE:/ SY-ULINE(100).
      FORMAT COLOR 1.
      WRITE:/1   SY-VLINE,
             2   TEXT-H01,              " Vendor Number
             17  SY-VLINE,
             18  TEXT-H02,              " Company Code
             31  SY-VLINE,
             32  TEXT-H04,              " Message
             100 SY-VLINE.
      FORMAT COLOR OFF.
      WRITE:/ SY-ULINE(100).
      LOOP AT IT_noupdate INTO WA_IT_noupdate.
        FORMAT COLOR 2.
        WRITE:/1   SY-VLINE,
               2   WA_IT_noupdate-LIFNR,
               17  SY-VLINE,
               18  WA_IT_noupdate-BUKRS,
               31  SY-VLINE,
               32  WA_IT_noupdate-MSG,
               100 SY-VLINE.
        CLEAR : WA_IT_noupdate.
        FORMAT COLOR OFF.
      ENDLOOP.
      WRITE:/ SY-ULINE(100).
    endform.                    " display_nochange_report
    *&      Form  ERROR_RECORD_DATA1
    Form to get Error Message for Changed Vendors
    form ERROR_RECORD_DATA1 .
      DATA : L_LINES TYPE I,
             L_MSG(200) TYPE C.
      DESCRIBE TABLE IT_MESSTAB LINES L_LINES.
      READ TABLE IT_MESSTAB INTO WA_IT_MESSTAB INDEX L_LINES.
      IF SY-SUBRC = 0.
        CLEAR L_MSG.
        CALL FUNCTION 'FORMAT_MESSAGE'
          EXPORTING
            ID        = WA_IT_MESSTAB-MSGID
            LANG      = SY-LANGU
            NO        = WA_IT_MESSTAB-MSGNR
            V1        = WA_IT_MESSTAB-MSGV1
            V2        = WA_IT_MESSTAB-MSGV2
            V3        = WA_IT_MESSTAB-MSGV3
            V4        = WA_IT_MESSTAB-MSGV4
          IMPORTING
            MSG       = L_MSG
          EXCEPTIONS
            NOT_FOUND = 1
            OTHERS    = 2.
        IF SY-SUBRC = 0.
          WA_IT_ERROR_fk02-MSG = L_MSG.
        ENDIF.
        IF P_VENMAS = 'X'.
          WA_IT_ERROR_fk02-LIFNR = WA_IT_VENDOR_MASTER-LIFNR.
          WA_IT_ERROR_fk02-BUKRS = WA_IT_VENDOR_MASTER-BUKRS.
        ELSEIF P_VENEXT = 'X'.
          WA_IT_ERROR_fk02-LIFNR = WA_IT_VENDOR_EXTEND-LIFNR.
          WA_IT_ERROR_fk02-BUKRS = WA_IT_VENDOR_EXTEND-BUKRS.
        ENDIF.
        APPEND WA_IT_ERROR_fk02 TO IT_ERROR_fk02.
        CLEAR WA_IT_ERROR_fk02.
      ENDIF.
    endform.                    " ERROR_RECORD_DATA1
    *&      Form  display_error_report_fk01
    Form to display Error Report for Master Vendors (FK01)
    form display_error_report_fk01 .
      IF P_VENMAS = 'X'.
        WRITE:/ TEXT-O05.     " Error List for Vendor Master (FK01)
      ELSEIF P_VENEXT = 'X'.
        WRITE:/ TEXT-O06.     " Error List for Vendor Master Extended (FK01)
      ENDIF.
      WRITE:/ SY-ULINE(100).
      FORMAT COLOR 1.
      WRITE:/1   SY-VLINE,
             2   TEXT-H01,              " Vendor Number
             17  SY-VLINE,
             18  TEXT-H02,              " Company Code
             31  SY-VLINE,
             32  TEXT-H04,              " Message
             100 SY-VLINE.
      FORMAT COLOR OFF.
      WRITE:/ SY-ULINE(100).
      LOOP AT IT_ERROR_fk01 INTO WA_IT_ERROR_fk01.
        FORMAT COLOR 2.
        WRITE:/1   SY-VLINE,
               2   WA_IT_ERROR_fk01-LIFNR,
               17  SY-VLINE,
               18  WA_IT_ERROR_fk01-BUKRS,
               31  SY-VLINE,
               32  WA_IT_ERROR_fk01-MSG,
               100 SY-VLINE.
        CLEAR : WA_IT_ERROR_fk01.
        FORMAT COLOR OFF.
      ENDLOOP.
      WRITE:/ SY-ULINE(100).
    endform.                    " display_error_report_fk01
    *&      Form  display_error_report_fk02
    Form to display Error Report for changed Vendors (FK02)
    form display_error_report_fk02 .
      IF P_VENMAS = 'X'.
        WRITE:/ TEXT-O14.     " Error List for Vendor Master (FK02)
      ELSEIF P_VENEXT = 'X'.
        WRITE:/ TEXT-O15.     " Error List for Vendor Master Extended (FK02)
      ENDIF.
      WRITE:/ SY-ULINE(100).
      FORMAT COLOR 1.
      WRITE:/1   SY-VLINE,
             2   TEXT-H01,              " Vendor Number

  • Material master data upload in wms

    Dear all ,
    Kindly explain me how to upload the material master data in WMS.
    Thanx in advance.
    Regards,
    velu

    Hi Velu
    You have to load this in a normal way you do it with LSMW.
    Additionally you have to update the warehouse view fields too.
    Select the batch input recording in LSMW and go to the MM01 transaction enter all the required fields including WM views.
    If you handle material with fixed bin strategy & Replenishment scenario, you have to create a material by selecting the respective storage type in "selection view tab"
    Regards
    edwin

  • Material Master Data upload approach

    Hi,
    I have a requirement to upload material master data into D.B
    1. Which is the best option to use - BDC/LSMW/BAPI(Program)/Direct upload program!
    2. Based on Material types fields to be uploaded will change as per sample sheet,
       Can we make use of single sheet With all fields in it(By removing common fields for all Mat.Types)!
    Will BAPI - BAPI_MATERIAL_SAVEDATA useful for both MM01/MM02!
    What is the better approach for the same!
    Thanks,
    Deep.

    Hi,
    I have 2 queations in addition to above.
    1. If i write a program using above BAPI for material master data. Then will it be better approach than LSMW with BAPI?
    In this case user will trigger Z tcode & he will select input file from desktop & execute & report log will be shown in the output with successful & unsuccessful materials.
    2. I have to upload material master data. Now i have got sample files for Basic, Plant & Sales organization specific.
    If i have single excel file (All fields in one single sheet/line) which covers all unique fields of material master related to diff Basic, Plant & Sales organization specific data & also for all diffrent material types will that be fine (or) it usually required seperate excel sheets for diffrent kinds of data!
    Please clarify about above 2 issues!
    Thanks in advance.
    Thanks,
    Deep.
    Edited by: Deep on May 12, 2009 6:56 AM

  • MATERIAL MASTER DATA UPLOADING THROUGH  LSMW

    Hi.
    I am new to lsmw.
    we have a requirement to upload the material master data through LSMW,.
    the data is on Excel sheet on the Desktop of the system.
    Can any body help me to upload the Material Master data, procedure in step wise.
    Thanks in advance,
    regards,
    Eswar.M

    Hi Venkat,
    Go through the following Steps
    Using Tcode MM01 -- Maintain the source fields are
    1) mara-amtnr  char(18)
    2) mara-mbrsh  char(1)
    3) mara-mtart  char(4)
    4) makt-maktx  char(40)
    5) mara-meins  char(3)
    the flate file format is like this as follows
    MAT991,C,COUP,Srinivas material01,Kg
    MAT992,C,COUP,Srinivas material02,Kg
    AMT993,C,COUP,Srinivas material03,Kg
    MAT994,C,COUP,Srinivas material04,Kg
    MAT995,C,COUP,Srinivas material05,Kg
    goto Tcode LSMW
    give Project Name
         Subproject Name
         object Name
    Press Enter -
    Press Execute Button
    It gives 13 radio-Button Options
    do the following 13 steps as follows
    1) select radio-Button 1 and execute
       Maintain Object Attributes
    select Standard Batch/Direct Input
       give Object -- 0020
           Method -- 0000
       save & Come Back
    2) select radio-Button 2 and execute
       Maintain Source Structures
       select the source structure and got to click on create button
       give source structure name & Description
       save & Come Back
    3) select radio-Button 3 and execute
       Maintain Source Fields
       select the source structure and click on create button
       give
       first field
            field name    matnr
            Field Label   material Number
            Field Length  18
            Field Type    C
       Second field
            field name    mbrsh
            Field Label   Industrial Sector
            Field Length  1
            Field Type    C
       Third field
            field name    mtart
            Field Label   material type
            Field Length  4
            Field Type    C
       fourth field
            field name    maktx
            Field Label   material description
            Field Length  40
            Field Type    C
       fifth field
            field name    meins
            Field Label   base unit of measurement
            Field Length  3
            Field Type    C
      save & come back
    4) select radio-Button 4 and execute
       Maintain Structure Relations
       go to blue lines 
          select first blue line and click on create relationship button
          select Second blue line and click on create relationship button
          select Third blue line and click on create relationship button
      save & come back
    5) select radio-Button 5 and execute
       Maintain Field Mapping and Conversion Rules
       Select the Tcode and click on Rule button there you will select constant
       and press continue button
       give Transaction Code : MM01 and press Enter
       after that
       1) select MATNR field click on Source filed(this is the field mapping) select MATNR and press Enter
       2) select MBRSH field click on Source filed(this is the field mapping) select MBRSH and press Enter
       3) select MTART field click on Source filed(this is the field mapping) select MTART and press Enter
       4) select MAKTX field click on Source filed(this is the field mapping) select MAKTX and press Enter
       5) select MEINS field click on Source filed(this is the field mapping) select MEINS and press Enter
      finally     
      save & come back
    6) select radio-Button 6 and execute
       Maintain Fixed Values, Translations, User-Defined Routines
       Create FIXED VALUE Name & Description as MM01
       Create Translations Name & Description as MM01
       Create User-Defined Routines Name & Description as MM01
       after that delete  all the above three just created in the 6th step
       FIXED VALUE --MM01
       Translations --MM01
       User-Defined Routines --MM01
       come back
    7) select radio-Button 7 and execute
       Specify Files
       select On the PC (Frontend) -- and click on Create button(f5)
                                      give the path of the file like "c:\material_data.xls"
                                      description : -
                                      separators as select tab radiao- button
       and press enter   save & come back
    8) select radio-Button 8 and execute
       Assign Files
       Save & come back
    9) select radio-Button 9 and execute
       Read Files
       Execute
       come back
       come back
    10) select radio-Button 10 and execute
        Display Imported Data
        Execute and press enter
        come back
        Come back
    11) select radio-Button 11 and execute
        Convert Data
        Execute
        come back
        Come back
    12) select radio-Button 12 and execute
        Display Converted Data
        Execute & come back
    13) select radio-Button 13 and execute
        Start Direct Input Program
       select the Program
       select continue button
    go with via physical file
    give the lock mode as 'E'
    and execute
    Regards
    Sreeni

  • Transferring MATERIAL MASTER DATA USING lsmw

    I am using LSMW to transfer material master data from text file using direct input program RMDATIND.  The problem is that the field WRKST in screen is of 48 characters while the batch data structure BMMH1 of field WRKST contains 14 characters. How can we transfer the full 48 characters in text file to THE FIELD BMMH1 IN DIRECT INPUT PROGRAM. Can we write any translation or routines . If yes, how is it possible. I can do the same using BDC but our client is already using the LSMW , only the new field WRKST for material has to be inserted. It is picking only 14 characters.
    Regards
    Debopriyo

    Hi
    Kindly use the sap note 351557 it is applicable for your release
    if you have any further clarifications let me know
    Regards
    Damu

  • Runtime error while creating material master data

    hello sir,
    i am facing one prolem while creating MATERIAL MASTER DATA.
    AFTER GIVING ALL REQUIRED INFORMATION WHEN I AM GOING TO SAVE THE DOCUMENT ITS SHOWING ABAP RUNTIME ERROR.
    MESSAGE TYPE: - MDS_KEYMAP.
    MESSAGE CLASS: 001.
    PLEASE TELL ME WHAT TO DO?
    REGARDS..

    SIR THANK YOU FOR YOUR REPLY.
    I ALREADY DONE THAT DUMP ANALYSIS.
    SO PLEASE KINDLY GIVE ME IN DETAILS ABOUT THAT SOLUTION...

  • Guidance for getting material master data from database table

    Hi,
    I need guidance to fetch following Material master data from the system data base.Please guide me for the same.
    BASIC DATA1
    BASIC DATA2
    MRP1,2,3,4
    WORK SCHEDULING
    QUALITY MANAGEMENT
    ACCOUNTING1
    ACCOUNTING2
    COSTING1,2
    PURCHASING
    PURCHASE ORDER TEXTSALES ORG1,2
    SALES GENERAL/PLANT
    PLANT DATA/STOR.1,2
    WAREHOUSE MGMNT1,2
    Also please tell me in general what is the reason for error while uploading the data into system using BAPi(AM talking about return message error).
    Thank you.
    Edited by: sanu debu on Feb 24, 2009 12:41 PM
    Edited by: sanu debu on Feb 24, 2009 12:42 PM

    Use BAPI's 
    BAPI_MATERIAL_GET_DETAIL
    BAPI_MATERIAL_GETALL
    BAPI_MATERIAL_GET_ALL

  • SAP Business Connector with Java (material master data)

    Hey,
    I have a question about the SAP BC. What are the steps I have to do, to use the BC with a Java program?
    My task is to create a program which downloads material master datas from SAP.
    I just installed the BC, and hope, that I did it correctly
    Many thanks in advance!!
    Kind regards,
    Alex
    German Version:
    Hey,
    wie ich oben schon geschrieben habe, habe ich ein paar Fragen zum SAP BC. Ich habe ein Hochschul-Projekt und muss hierfür Materialstammdaten aus SAP herunterladen und mit einem Java Programm ausgeben lassen.
    Kann mir vielleicht jemand weiterhelfen, wie die Schritte hierfür aussehen?! Wie verbinde ich den BC mit meinem SAP System? und wie bekomme ich anschließen die Daten mit einem Java Programm ausgelesen?
    Ich habe bereits den BC installiert und konnte mich meines Wissens auch richtig anmelden;-)
    Ich hoffe, dass mir jemand weiterhelfen kann und bedanke mich schon im Voraus für eventuelle Antworten!!!
    Viele Grüße
    Alex
    Edited by: Rolf Gersbacher on May 19, 2010 10:34 PM

    Hi,
    I work with SAP BC some time ago... I remember that you configure the connection in SM59 / SICF and the server open a port to "listen" (connect external).
    So, your external program can execute functions inside SAP and exchange data.
    See some links:
    http://en.wikipedia.org/wiki/SAP_Business_Connector
    http://help.sap.com/saphelp_nw04/helpdata/en/6a/3f93404f673028e10000000a1550b0/frameset.htm
    http://www.thespot4sap.com/articles/SAP_XML_Business_Integration.asp
    Best regards,
    Leandro Mengue

  • Non-SAP to SAP Material Master Data Transfer

    Hi Experts,
    Please indicate any standard tools in SAP and how to use it wherein we can migrate non-SAP material master data to SAP.
    Points will be awarded.
    Regards,
    LM

    Hello Leo,
    There are a number of options to do this. You can use the standard SAP tool named LSMW - Legacy System Migration Workbench (transaction LSMW) as a starting point.
    Also please read this [Documentation|http://help.sap.com/saphelp_47x200/helpdata/en/0d/414538bc0fe927e10000009b38f8cf/frameset.htm] before undertaking the data migration activity via LSMW.
    Additionally, there is also a Direct Input program available named RMDATIND - please go through the program documentation before you use it. You can use this program to transfer material master data to SAP but
    make sure you assign this program through LSMW for mapping structures etc. The internet link above will give
    more details and step-by-step instructions to follow.
    Hope this helps,
    Cheers,
    Sougata.
    p.s. It is sad to see useful answers remain unrewarded such as this one!
    Edited by: Sougata Chatterjee on May 9, 2008 10:13 PM

  • Multiple group - single material master data

    Dear friends ,
    I am doing material master data as follows.
    Ex. Water Bottle - Material Group -  may be (Aqua) or (Bislary) or (Saiganga) or (Balley).
    means when i will make material master it will become 4 material master with 4 group as bellow.
    1) Water bottel-Aqua
    2 )water bottle-Bislary
    3 )Water bottle-Saiganga
    4) Water bottle-Balley.
    By my requirement is that it should be only one material master code , with facility of 4 material group.
    Whatever i need i will select at the time of PO.
    Regards,
    Mahesh.

    Hi,
    You just go for single material code creation as WATERBOTTLE and then as you needed, you can go for Split Valuation where same material WATERBOTTLE at a plant can have different stock quantity and value for different groupings {(Aqua) or (Bislary) or (Saiganga) or (Balley)}
    http://www.sap123.com/a/29/#split-valuation
    OR
    Go for Batch Management where you are just subdividing the material WATERBOTTLE according to the characteristics{(Aqua) or (Bislary) or (Saiganga) or (Balley)}
    https://wiki.sdn.sap.com/wiki/display/ERPLO/Batch+Management
    Regards,
    Biju K

  • LSMW for  Vendor Master using Batch Input/Direct

    Hi Folk,
    I'm trying to create a LSMW for  Vendor Master using Batch Input/Direct Input and in the step Create Batch Inout Session a error message appears:
    Trans.     1 XK01: Acct already exists; general area not being processed.
    Can somebody help me with this...........

    Hi,
    Check manually create vendor. Check with recording steps means strucutre creadred while you choose BDC recording option. With same data r u able to create vendor.
    Regards
    Md.MahaboobKhan

Maybe you are looking for

  • Webi report on top of dervied tables

    Hi Team, We are going to work on a migration work from Discoverer to BO 4.1. As per my understanding in discoverer each tab in a report has a SQL query (We have oracle as DB) which will be used to build that tab. Same for the next tab, it will have i

  • How to manage SAP Masters Data in Multi Lauguages

    Dear All; We are using ECC5 unicode version. So far we only use in Japan, but we are trying to use this system in Thailand too. And some of the customer and vendor master record will be used in JPN and THI. I would like to know how to save the 2 lang

  • Square at end of each line in entourage mail

    Help please! I have searched the internet, unsuccessfully, to find out how to remove a square box that shows itself at the end of each line of text in my entourage mail... whether incoming or composed mail.... Does anyone have an answer? Thanks so mu

  • IPhone 4S Coverage Issues

    Hi, If i loose service on my iPhone 4S it then will not get coverage until i reboot. This is very anoying when im travelling because rebooting an iPhone isnt the quickest process. So whenever my iPhone shows 'No Service' it wont search for service un

  • Download/Display the image files stored at KM location: J2EE application

    Hi All Please let me know how to download/Display the image files stored at KM location on portal using J2EE application. Thanks. Best Regards P M