<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: bdc program for mi01(inventory) error in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/bdc-program-for-mi01-inventory-error/m-p/3988933#M952925</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Report  ZTEST_PRG6
*&amp;amp;
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;
*&amp;amp;
*&amp;amp;---------------------------------------------------------------------*

report anirban no standard page heading line-size 255.

types : begin of ty_upload ,
        werks type ikpf-werks,
        lgort type ikpf-lgort,
        matnr type iseg-matnr,
        end of ty_upload.

parameters: p_file type localfile obligatory.


data:t_upload type standard table of ty_upload initial size 0,
*internal table for bdcdata.
     t_bdcdata type standard table of bdcdata initial size 0 ,
*internal table for bdcmsgcoll.
     t_bdcmsgcoll type standard table of bdcmsgcoll initial size 0,
     t_error type standard table of ty_upload initial size 0,
     w_upload type ty_upload,
     w_file   type string,
     bdcdata type bdcdata,
     w_bdcmsg type bdcmsgcoll,
*global variable declaration.
    g_message(70) type c.


at selection-screen on value-request for p_file.


  call function 'F4_FILENAME'
    exporting
      program_name  = syst-cprog
      dynpro_number = syst-dynnr
    importing
      file_name     = p_file.


start-of-selection.

  w_file = p_file.

  call function 'GUI_UPLOAD'
    exporting
      filename            = w_file
      filetype            = 'ASC'
      has_field_separator = 'X'
    tables
      data_tab            = t_upload.

  check sy-subrc = 0.

  call function 'BDC_OPEN_GROUP'
    exporting
      client = sy-mandt
      group  = 'ERROR_MAT'
      user   = sy-uname
      prog   = sy-cprog.

  check sy-subrc = 0.

  loop at t_upload into w_upload.

    refresh t_bdcdata.

    perform bdc_dynpro using 'SAPMM07I' '0700'.
    perform bdc_field using 'BDC_CURSOR'
    'IKPF-LGORT'.
    perform bdc_field using 'BDC_OKCODE' '/00'.
    perform bdc_field using 'IKPF-WERKS'
    'W_UPLOAD-WERKS'.
    perform bdc_field using 'IKPF-LGORT'
    'W_UPLOAD-LGORT'.
    perform bdc_field using 'RM07I-XLVOCA'
    'X'.
    perform bdc_dynpro using 'SAPMM07I' '0721'.
    perform bdc_field using 'BDC_CURSOR'
    'ISEG-MATNR(02)'.
    perform bdc_field using 'BDC_OKCODE'
    '/00'.
    perform bdc_field using 'ISEG-MATNR(01)'
    'W_UPLOAD-MATNR(01)'.
*perform bdc_field using 'ISEG-MATNR(02)'
    perform bdc_dynpro using 'SAPMM07I' '0721'.
    perform bdc_field using 'BDC_CURSOR'
    'ISEG-MATNR(01)'.
    perform bdc_field using 'BDC_OKCODE'
    '=BU'.
    call transaction 'MI01' using t_bdcdata mode 'N' update 'S'
    messages into t_bdcmsgcoll.
    if sy-subrc = 0.

      call function 'BDC_INSERT'
        exporting
          tcode     = 'MI01'
        tables
          dynprotab = t_bdcdata.

    endif.

    clear w_bdcmsg.
    read table t_bdcmsgcoll into w_bdcmsg index 1.

    call function 'FORMAT_MESSAGE'
      exporting
        id        = w_bdcmsg-msgid
        lang      = sy-langu
        no        = w_bdcmsg-msgnr
        v1        = w_bdcmsg-msgv1
        v2        = w_bdcmsg-msgv2
        v3        = w_bdcmsg-msgv3
        v4        = w_bdcmsg-msgv4
      importing
        msg       = g_message
      exceptions
        not_found = 1
        others    = 2.
    if sy-subrc = 0.

      write:/ w_upload-werks,'----', g_message.

      refresh t_bdcmsgcoll.

    endif.

  endloop.
  call function 'BDC_CLOSE_GROUP'.


* ----------------------------------------------------------------------
* start new screen
* ----------------------------------------------------------------------
form bdc_dynpro using program dynpro.
  clear bdcdata.
  bdcdata-program = program.
  bdcdata-dynpro = dynpro.
  bdcdata-dynbegin = 'X'.
  append bdcdata to t_bdcdata.
  clear bdcdata.
endform.                    "

* --------------------------------------------------------------------
*insert field *
*---------------------------------------------------------------------
form bdc_field using fnam fval.

*  IF fval NODATA.
  clear bdcdata.
  bdcdata-fnam = fnam.
  bdcdata-fval = fval.
  append bdcdata to t_bdcdata.
  clear bdcdata.

*  ENDIF.
endform.                    "

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please change the program as above &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope That Helps&lt;/P&gt;&lt;P&gt;Anirban M.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 10 Jun 2008 11:29:45 GMT</pubDate>
    <dc:creator>former_member480923</dc:creator>
    <dc:date>2008-06-10T11:29:45Z</dc:date>
    <item>
      <title>bdc program for mi01(inventory) error</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bdc-program-for-mi01-inventory-error/m-p/3988932#M952924</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI EXPERTS,&lt;/P&gt;&lt;P&gt;   i have written a coding as per the requirement for inventory data upload by using transaction code 'MI01'.but it is always showing an error that " flat file is not found".please help me in solving this problem.&lt;/P&gt;&lt;P&gt;here is the coding.&lt;/P&gt;&lt;P&gt;report ZMM_RDD0009_MATERIAL_INVENTORY&lt;/P&gt;&lt;P&gt;       no standard page heading line-size 255.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;structure declaration.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;types : begin of TY_UPLOAD ,&lt;/P&gt;&lt;P&gt;        WERKS TYPE IKPF-WERKS,&lt;/P&gt;&lt;P&gt;        LGORT TYPE IKPF-LGORT,&lt;/P&gt;&lt;P&gt;        MATNR TYPE ISEG-MATNR,&lt;/P&gt;&lt;P&gt;        END OF TY_UPLOAD.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;INTERNAL TABLE DECLARATION.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;internal table for upload the data.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;data:t_upload type standard table of ty_upload initial size 0,&lt;/P&gt;&lt;P&gt;*internal table for bdcdata.&lt;/P&gt;&lt;P&gt;     t_bdcdata type standard table of bdcdata initial size 0 ,&lt;/P&gt;&lt;P&gt;*internal table for bdcmsgcoll.&lt;/P&gt;&lt;P&gt;     t_bdcmsgcoll type standard table of bdcmsgcoll initial size 0,&lt;/P&gt;&lt;P&gt;     t_error type standard table of ty_upload initial size 0,&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;WORK-AREA DECLARATION.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;work-area for upload the data.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;     w_upload type ty_upload,&lt;/P&gt;&lt;P&gt;     bdcdata type bdcdata,&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;work-area for bdcmsgcoll.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;     w_bdcmsg type bdcmsgcoll,&lt;/P&gt;&lt;P&gt;*global variable declaration.&lt;/P&gt;&lt;P&gt;     g_message(70) type c.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*include bdcrecx1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;start-of-selection.&lt;/P&gt;&lt;P&gt;call function 'GUI_UPLOAD'&lt;/P&gt;&lt;P&gt;  exporting&lt;/P&gt;&lt;P&gt;    filename                      = 'D:/FLATFILE.TXT'&lt;/P&gt;&lt;P&gt;   filetype                      = 'ASC'&lt;/P&gt;&lt;P&gt;   has_field_separator           = 'X'&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  HEADER_LENGTH                 = 0&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  READ_BY_LINE                  = 'X'&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  DAT_MODE                      = ' '&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;IMPORTING&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  FILELENGTH                    =&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  HEADER                        =&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  tables&lt;/P&gt;&lt;P&gt;    data_tab                      = t_upload.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;call function 'BDC_OPEN_GROUP'&lt;/P&gt;&lt;P&gt; exporting&lt;/P&gt;&lt;P&gt;   client                    = sy-mandt&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  DEST                      = FILLER8&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;   group                     = 'ERROR_MAT'&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  HOLDDATE                  = ''&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  KEEP                      = 'X'&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;   user                      = sy-uname&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  RECORD                    = FILLER1&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;   prog                      = sy-cprog.&lt;/P&gt;&lt;P&gt;loop at t_upload into w_upload.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;refresh t_bdcdata.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*perform open_group.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;perform bdc_dynpro      using 'SAPMM07I' '0700'.&lt;/P&gt;&lt;P&gt;perform bdc_field       using 'BDC_CURSOR'&lt;/P&gt;&lt;P&gt;                              'IKPF-LGORT'.&lt;/P&gt;&lt;P&gt;perform bdc_field       using 'BDC_OKCODE'&lt;/P&gt;&lt;P&gt;                              '/00'.&lt;/P&gt;&lt;P&gt;*perform bdc_field       using 'RM07I-BLDAT'&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;                             'W_UPLOAD-BLDAT'.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;*perform bdc_field       using 'RM07I-GIDAT'&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;                            'W_UPLOAD-GIDAT'.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;perform bdc_field       using 'IKPF-WERKS'&lt;/P&gt;&lt;P&gt;                              'W_UPLOAD-WERKS'.&lt;/P&gt;&lt;P&gt;perform bdc_field       using 'IKPF-LGORT'&lt;/P&gt;&lt;P&gt;                              'W_UPLOAD-LGORT'.&lt;/P&gt;&lt;P&gt;perform bdc_field       using 'RM07I-XLVOCA'&lt;/P&gt;&lt;P&gt;                              'X'.&lt;/P&gt;&lt;P&gt;perform bdc_dynpro      using 'SAPMM07I' '0721'.&lt;/P&gt;&lt;P&gt;perform bdc_field       using 'BDC_CURSOR'&lt;/P&gt;&lt;P&gt;                              'ISEG-MATNR(02)'.&lt;/P&gt;&lt;P&gt;perform bdc_field       using 'BDC_OKCODE'&lt;/P&gt;&lt;P&gt;                              '/00'.&lt;/P&gt;&lt;P&gt;perform bdc_field       using 'ISEG-MATNR(01)'&lt;/P&gt;&lt;P&gt;                              'W_UPLOAD-MATNR(01)'.&lt;/P&gt;&lt;P&gt;*perform bdc_field       using 'ISEG-MATNR(02)'&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;                             'W_UPLOAD-MATNR(02)'.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;perform bdc_dynpro      using 'SAPMM07I' '0721'.&lt;/P&gt;&lt;P&gt;perform bdc_field       using 'BDC_CURSOR'&lt;/P&gt;&lt;P&gt;                              'ISEG-MATNR(01)'.&lt;/P&gt;&lt;P&gt;perform bdc_field       using 'BDC_OKCODE'&lt;/P&gt;&lt;P&gt;                              '=BU'.&lt;/P&gt;&lt;P&gt;*perform bdc_transaction using 'MI01'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*perform close_group.&lt;/P&gt;&lt;P&gt;call transaction 'MI01' using t_bdcdata mode 'N' update 'S'&lt;/P&gt;&lt;P&gt;                   messages into t_bdcmsgcoll.&lt;/P&gt;&lt;P&gt;if sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;*append w_upload to t_error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;call function 'BDC_INSERT'&lt;/P&gt;&lt;P&gt; exporting&lt;/P&gt;&lt;P&gt;   tcode                  = 'MI01'&lt;/P&gt;&lt;P&gt;  tables&lt;/P&gt;&lt;P&gt;    dynprotab              = t_bdcdata.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;clear w_bdcmsg.&lt;/P&gt;&lt;P&gt;read table t_bdcmsgcoll into w_bdcmsg index 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;call function 'FORMAT_MESSAGE'&lt;/P&gt;&lt;P&gt; exporting&lt;/P&gt;&lt;P&gt;   id              = w_bdcmsg-msgid&lt;/P&gt;&lt;P&gt;   lang            = sy-langu&lt;/P&gt;&lt;P&gt;   no              = w_bdcmsg-msgnr&lt;/P&gt;&lt;P&gt;   v1              = w_bdcmsg-msgv1&lt;/P&gt;&lt;P&gt;   v2              = w_bdcmsg-msgv2&lt;/P&gt;&lt;P&gt;   v3              = w_bdcmsg-msgv3&lt;/P&gt;&lt;P&gt;   v4              = w_bdcmsg-msgv4&lt;/P&gt;&lt;P&gt; importing&lt;/P&gt;&lt;P&gt;   msg             = g_message&lt;/P&gt;&lt;P&gt; exceptions&lt;/P&gt;&lt;P&gt;   not_found       = 1&lt;/P&gt;&lt;P&gt;   others          = 2.&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;write:/ w_upload-WERKS,'----', g_message.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;refresh t_bdcmsgcoll.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;call function 'BDC_CLOSE_GROUP'.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  NOT_OPEN          = 1&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  QUEUE_ERROR       = 2&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  OTHERS            = 3&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;          .&lt;/P&gt;&lt;P&gt;if sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;       Start new screen                                              *&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form bdc_dynpro using program dynpro.&lt;/P&gt;&lt;P&gt;  clear bdcdata.&lt;/P&gt;&lt;P&gt;  bdcdata-program  = program.&lt;/P&gt;&lt;P&gt;  bdcdata-dynpro   = dynpro.&lt;/P&gt;&lt;P&gt;  bdcdata-dynbegin = 'X'.&lt;/P&gt;&lt;P&gt;  append bdcdata to t_bdcdata.&lt;/P&gt;&lt;P&gt;  clear bdcdata.&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;       Insert field                                                  *&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form bdc_field using fnam fval.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; IF FVAL &amp;lt;&amp;gt; NODATA.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    clear bdcdata.&lt;/P&gt;&lt;P&gt;    bdcdata-fnam = fnam.&lt;/P&gt;&lt;P&gt;    bdcdata-fval = fval.&lt;/P&gt;&lt;P&gt;    append bdcdata to t_bdcdata.&lt;/P&gt;&lt;P&gt;    clear bdcdata.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; ENDIF.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: rohit on Jun 10, 2008 1:09 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jun 2008 11:09:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bdc-program-for-mi01-inventory-error/m-p/3988932#M952924</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-10T11:09:14Z</dc:date>
    </item>
    <item>
      <title>Re: bdc program for mi01(inventory) error</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bdc-program-for-mi01-inventory-error/m-p/3988933#M952925</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Report  ZTEST_PRG6
*&amp;amp;
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;
*&amp;amp;
*&amp;amp;---------------------------------------------------------------------*

report anirban no standard page heading line-size 255.

types : begin of ty_upload ,
        werks type ikpf-werks,
        lgort type ikpf-lgort,
        matnr type iseg-matnr,
        end of ty_upload.

parameters: p_file type localfile obligatory.


data:t_upload type standard table of ty_upload initial size 0,
*internal table for bdcdata.
     t_bdcdata type standard table of bdcdata initial size 0 ,
*internal table for bdcmsgcoll.
     t_bdcmsgcoll type standard table of bdcmsgcoll initial size 0,
     t_error type standard table of ty_upload initial size 0,
     w_upload type ty_upload,
     w_file   type string,
     bdcdata type bdcdata,
     w_bdcmsg type bdcmsgcoll,
*global variable declaration.
    g_message(70) type c.


at selection-screen on value-request for p_file.


  call function 'F4_FILENAME'
    exporting
      program_name  = syst-cprog
      dynpro_number = syst-dynnr
    importing
      file_name     = p_file.


start-of-selection.

  w_file = p_file.

  call function 'GUI_UPLOAD'
    exporting
      filename            = w_file
      filetype            = 'ASC'
      has_field_separator = 'X'
    tables
      data_tab            = t_upload.

  check sy-subrc = 0.

  call function 'BDC_OPEN_GROUP'
    exporting
      client = sy-mandt
      group  = 'ERROR_MAT'
      user   = sy-uname
      prog   = sy-cprog.

  check sy-subrc = 0.

  loop at t_upload into w_upload.

    refresh t_bdcdata.

    perform bdc_dynpro using 'SAPMM07I' '0700'.
    perform bdc_field using 'BDC_CURSOR'
    'IKPF-LGORT'.
    perform bdc_field using 'BDC_OKCODE' '/00'.
    perform bdc_field using 'IKPF-WERKS'
    'W_UPLOAD-WERKS'.
    perform bdc_field using 'IKPF-LGORT'
    'W_UPLOAD-LGORT'.
    perform bdc_field using 'RM07I-XLVOCA'
    'X'.
    perform bdc_dynpro using 'SAPMM07I' '0721'.
    perform bdc_field using 'BDC_CURSOR'
    'ISEG-MATNR(02)'.
    perform bdc_field using 'BDC_OKCODE'
    '/00'.
    perform bdc_field using 'ISEG-MATNR(01)'
    'W_UPLOAD-MATNR(01)'.
*perform bdc_field using 'ISEG-MATNR(02)'
    perform bdc_dynpro using 'SAPMM07I' '0721'.
    perform bdc_field using 'BDC_CURSOR'
    'ISEG-MATNR(01)'.
    perform bdc_field using 'BDC_OKCODE'
    '=BU'.
    call transaction 'MI01' using t_bdcdata mode 'N' update 'S'
    messages into t_bdcmsgcoll.
    if sy-subrc = 0.

      call function 'BDC_INSERT'
        exporting
          tcode     = 'MI01'
        tables
          dynprotab = t_bdcdata.

    endif.

    clear w_bdcmsg.
    read table t_bdcmsgcoll into w_bdcmsg index 1.

    call function 'FORMAT_MESSAGE'
      exporting
        id        = w_bdcmsg-msgid
        lang      = sy-langu
        no        = w_bdcmsg-msgnr
        v1        = w_bdcmsg-msgv1
        v2        = w_bdcmsg-msgv2
        v3        = w_bdcmsg-msgv3
        v4        = w_bdcmsg-msgv4
      importing
        msg       = g_message
      exceptions
        not_found = 1
        others    = 2.
    if sy-subrc = 0.

      write:/ w_upload-werks,'----', g_message.

      refresh t_bdcmsgcoll.

    endif.

  endloop.
  call function 'BDC_CLOSE_GROUP'.


* ----------------------------------------------------------------------
* start new screen
* ----------------------------------------------------------------------
form bdc_dynpro using program dynpro.
  clear bdcdata.
  bdcdata-program = program.
  bdcdata-dynpro = dynpro.
  bdcdata-dynbegin = 'X'.
  append bdcdata to t_bdcdata.
  clear bdcdata.
endform.                    "

* --------------------------------------------------------------------
*insert field *
*---------------------------------------------------------------------
form bdc_field using fnam fval.

*  IF fval NODATA.
  clear bdcdata.
  bdcdata-fnam = fnam.
  bdcdata-fval = fval.
  append bdcdata to t_bdcdata.
  clear bdcdata.

*  ENDIF.
endform.                    "

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please change the program as above &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope That Helps&lt;/P&gt;&lt;P&gt;Anirban M.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jun 2008 11:29:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bdc-program-for-mi01-inventory-error/m-p/3988933#M952925</guid>
      <dc:creator>former_member480923</dc:creator>
      <dc:date>2008-06-10T11:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: bdc program for mi01(inventory) error</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bdc-program-for-mi01-inventory-error/m-p/3988934#M952926</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rohit,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Declare a paramter in selection screen say,&lt;/P&gt;&lt;P&gt;P_file type rlgrap-filename.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Default the file path to this parameter and pass p_file to the parameter filename in the FM gui_upload.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Keerthi.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jun 2008 11:30:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bdc-program-for-mi01-inventory-error/m-p/3988934#M952926</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-10T11:30:34Z</dc:date>
    </item>
  </channel>
</rss>

