<?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: Help with BDCs and flat files..... in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-bdcs-and-flat-files/m-p/957798#M66694</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One more help guys....&lt;/P&gt;&lt;P&gt;The above program was for BOM creation. &lt;/P&gt;&lt;P&gt;Does anyone have a BDC program that uploads HEADER info. and ITEM information from a flat file onto SAP.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 02 Aug 2005 04:58:43 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2005-08-02T04:58:43Z</dc:date>
    <item>
      <title>Help with BDCs and flat files.....</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-bdcs-and-flat-files/m-p/957793#M66689</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;one help required. This is regarding Contracts in SAP&lt;/P&gt;&lt;P&gt;Transaction va41.&lt;/P&gt;&lt;P&gt;Can anyone of you here..give me a flat file&lt;/P&gt;&lt;P&gt;having details of "contracts" with header information and item level information, and a BDC program to upload it to SAP? I'm sure someone would have worked here with a similar scenario. For that matter any transaction, can anyone give me a flat file containing header and item details and a BDC to read the flat file and upload data onto SAP.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Aug 2005 13:02:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-bdcs-and-flat-files/m-p/957793#M66689</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-08-01T13:02:26Z</dc:date>
    </item>
    <item>
      <title>Re: Help with BDCs and flat files.....</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-bdcs-and-flat-files/m-p/957794#M66690</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey any help...?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Aug 2005 13:52:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-bdcs-and-flat-files/m-p/957794#M66690</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-08-01T13:52:15Z</dc:date>
    </item>
    <item>
      <title>Re: Help with BDCs and flat files.....</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-bdcs-and-flat-files/m-p/957795#M66691</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Run the transaction thru SHDB and create a recording.  Then implement that BDC code in a program.  Here is a sample "Upload" program which uses a BDC.  This particular program allocates BOMs to plants.  You can use this program as a template for your program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

report zmmbomallplt
       no standard page heading.

type-pools: icon, slis.

types: begin of tflatf,
        rec(300) type c,
       end of tflatf,

       begin of tdata,
       matnr type mast-matnr,
       werks type mast-werks,
       stlan type mast-stlan,
       zwerk type mast-werks,
       end of tdata,

       begin of tmess,
        status type icon,
        matnr type mast-matnr,
        werks type mast-werks,
        stlan type mast-stlan,
        zwerk type mast-werks,
        mgtxt(100) type c,
       end of tmess.

data: iflatf type table of tflatf.
data: idata  type table of tdata  with header line.
data: imess  type table of tmess  with header line.
data: bdcmess type table of bdcmsgcoll with header line.
data: bdcdata type table of bdcdata    with header line.
data: fieldcat type slis_t_fieldcat_alv.

* Selection Screen
selection-screen begin of block b1 with frame title text-002 .
parameters: p_file type localfile default 'C:BomAllocation.txt'.
selection-screen end of block b1.

at selection-screen on value-request for p_file.
  call function 'KD_GET_FILENAME_ON_F4'
       exporting
            static    = 'X'
       changing
            file_name = p_file.

at selection-screen.

  clear idata. refresh idata.
  perform upload_data.
  perform check_file_format.


start-of-selection.

  clear imess. refresh imess.

  perform show_status using 'Processing File'.

  loop at idata.
    perform call_transaction.
  endloop.

  perform call_alv.

************************************************************************
* CHECK_FILE_FORMAT
************************************************************************
form check_file_format.

  data: xflatf like line of iflatf.
  data: xmara type mara.
  data: xt001w type t001w.
  data: message(100) type c.

  read table iflatf into xflatf index 1.
  search xflatf-rec for ','.
  if sy-subrc &amp;lt;&amp;gt; 0.
    message e016(mm).
  else.
    loop at iflatf into xflatf.
      split xflatf-rec at ',' into idata-matnr idata-werks
                                   idata-stlan idata-zwerk.

* Convert material number to internal.
      call function 'CONVERSION_EXIT_MATN1_INPUT'
           exporting
                input  = idata-matnr
           importing
                output = idata-matnr.

      select single * from mara into xmara
                 where matnr = idata-matnr.
      if sy-subrc &amp;lt;&amp;gt; 0.
        message e398(00) with 'Material' space idata-matnr
                  'is not a valid material. Please check file'.
      endif.

      select single * from t001w into xt001w
                 where werks = idata-werks.
      if sy-subrc &amp;lt;&amp;gt; 0.
        message e398(00) with 'Plant' idata-werks
                          'is not a valid plant. Please check file.'.
      endif.

      select single * from t001w into xt001w
                 where werks = idata-zwerk.
      if sy-subrc &amp;lt;&amp;gt; 0.
        message e398(00) with 'Allocate To Plant' idata-zwerk
                          'is not a valid plant. Please check file.'.
      endif.

      append idata.
    endloop.
  endif.

endform.

************************************************************************
* Upload_Data
************************************************************************
form upload_data.

  data: filename type string.

  filename = p_file.

  perform show_status using 'Uploading File..........'.

  call method cl_gui_frontend_services=&amp;gt;gui_upload
         exporting
              filename                = filename
              filetype                = 'ASC'
         changing
              data_tab                = iflatf
         exceptions
              file_open_error         = 1
              file_read_error         = 2
              no_batch                = 3
              gui_refuse_filetransfer = 4
              no_authority            = 6
              unknown_error           = 7
              bad_data_format         = 8
              unknown_dp_error        = 12
              access_denied           = 13
              others                  = 17.

  if sy-subrc ne 0.
    message id sy-msgid type sy-msgty number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    exit.
  endif.

endform.

************************************************************************
*  FORM CALL_TRANSACTION
************************************************************************
form call_transaction.

  data: bdc_mode(1) type c value 'N'.

  perform bdc_dynpro      using 'SAPLCSAL' '0100'.
  perform bdc_field       using 'BDC_CURSOR'
                                'RC29N-ZWERK'.
  perform bdc_field       using 'BDC_OKCODE'
                                '/00'.
  perform bdc_field       using 'RC29N-MATNR'
                          idata-matnr.
  perform bdc_field       using 'RC29N-WERKS'
                          idata-werks.
  perform bdc_field       using 'RC29N-STLAN'
                          idata-stlan.
  perform bdc_field       using 'RC29N-ZWERK'
                          idata-zwerk.
  perform bdc_dynpro      using 'SAPLCSAL' '0120'.
  perform bdc_field       using 'BDC_CURSOR'
                                'RC29K-STLNR'.
  perform bdc_field       using 'BDC_OKCODE'
                                '=FCBU'.

  call transaction 'CS07' using bdcdata
          mode bdc_mode
          update 'S'
          messages into bdcmess.

* Handle "Success" message.
  read table bdcmess with key msgid = '29'
                              msgnr = '230'.
  if sy-subrc = 0.
    perform prepare_message using imess-mgtxt.
    move-corresponding idata to imess.
    write icon_green_light as icon to imess-status.
    append imess.
  else.
* Handle "Error Messages" messsages
    read table bdcmess with key msgtyp = 'E'.
    if sy-subrc = 0.
      perform prepare_message using imess-mgtxt.
    else.
      imess-mgtxt = 'Unknown Error'.
    endif.
    move-corresponding idata to imess.
    write icon_red_light as icon to imess-status.
    append imess.
  endif.

  clear: bdcdata, bdcmess.
  refresh: bdcdata, bdcmess.

endform.

************************************************************************
*      Form  BDC_DYNPRO
************************************************************************
form bdc_dynpro using  program dynpro.

  clear bdcdata.
  bdcdata-program = program.
  bdcdata-dynpro = dynpro.
  bdcdata-dynbegin = 'X'.
  append bdcdata.

endform.

************************************************************************
*      Form  BDC_FIELD
************************************************************************
form bdc_field using fnam fval.

  clear bdcdata.
  bdcdata-fnam = fnam.
  bdcdata-fval = fval.
  append bdcdata.

endform.

************************************************************************
*  FORM PREPARE_MESSAGE
************************************************************************
form prepare_message using message.

* Prepare message.
  clear message.
  call function 'MESSAGE_PREPARE'
       exporting
            language = sy-langu
            msg_id   = bdcmess-msgid
            msg_no   = bdcmess-msgnr
            msg_var1 = bdcmess-msgv1(50)
            msg_var2 = bdcmess-msgv2(50)
            msg_var3 = bdcmess-msgv3(50)
            msg_var4 = bdcmess-msgv4(50)
       importing
            msg_text = message.

endform.

************************************************************************
* SHOW_STATUS
************************************************************************
form show_status using text.

  call function 'SAPGUI_PROGRESS_INDICATOR'
       exporting
            text = text.

endform.

************************************************************************
*  CALL_ALV
************************************************************************
form call_alv.

  clear: fieldcat. refresh: fieldcat.

  data: tmp_fc type slis_fieldcat_alv .

  clear tmp_fc.
  tmp_fc-reptext_ddic = ' '.
  tmp_fc-fieldname    = 'STATUS'.
  tmp_fc-tabname      = 'IMESS'.
  tmp_fc-outputlen    = '4'.
  append tmp_fc to fieldcat.

  clear tmp_fc.
  tmp_fc-reptext_ddic = 'Material Number'.
  tmp_fc-fieldname    = 'MATNR'.
  tmp_fc-ref_fieldname = 'MATNR'.
  tmp_fc-ref_tabname  =  'MARA'.
  tmp_fc-tabname      = 'IMESS'.
  tmp_fc-outputlen    = '18'.
  append tmp_fc to fieldcat.

  clear tmp_fc.
  tmp_fc-reptext_ddic = 'Plant'.
  tmp_fc-fieldname    = 'WERKS'.
  tmp_fc-tabname      = 'IMESS'.
  tmp_fc-outputlen    = '4'.
  append tmp_fc to fieldcat.

  clear tmp_fc.
  tmp_fc-reptext_ddic = 'Bom Usage'.
  tmp_fc-fieldname    = 'STLAN'.
  tmp_fc-tabname      = 'IMESS'.
  tmp_fc-outputlen    = '4'.
  append tmp_fc to fieldcat.

  clear tmp_fc.
  tmp_fc-reptext_ddic = 'Allocate To Plant'.
  tmp_fc-fieldname    = 'ZWERK'.
  tmp_fc-tabname      = 'IMESS'.
  tmp_fc-outputlen    = '4'.
  append tmp_fc to fieldcat.

  clear tmp_fc.
  tmp_fc-reptext_ddic = 'Message'.
  tmp_fc-fieldname    = 'MGTXT'.
  tmp_fc-tabname      = 'IMESS'.
  tmp_fc-outputlen    = '60'.
  append tmp_fc to fieldcat.

* Call ABAP List Viewer (ALV)
  call function 'REUSE_ALV_GRID_DISPLAY'
       exporting
            it_fieldcat = fieldcat
       tables
            t_outtab    = imess.

endform.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Aug 2005 14:04:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-bdcs-and-flat-files/m-p/957795#M66691</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2005-08-01T14:04:38Z</dc:date>
    </item>
    <item>
      <title>Re: Help with BDCs and flat files.....</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-bdcs-and-flat-files/m-p/957796#M66692</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please award points if this post was helpful.  Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Aug 2005 14:05:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-bdcs-and-flat-files/m-p/957796#M66692</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2005-08-01T14:05:09Z</dc:date>
    </item>
    <item>
      <title>Re: Help with BDCs and flat files.....</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-bdcs-and-flat-files/m-p/957797#M66693</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rich,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the program. Can you provide me the flat file also.........just a request.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Aug 2005 04:22:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-bdcs-and-flat-files/m-p/957797#M66693</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-08-02T04:22:32Z</dc:date>
    </item>
    <item>
      <title>Re: Help with BDCs and flat files.....</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-bdcs-and-flat-files/m-p/957798#M66694</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One more help guys....&lt;/P&gt;&lt;P&gt;The above program was for BOM creation. &lt;/P&gt;&lt;P&gt;Does anyone have a BDC program that uploads HEADER info. and ITEM information from a flat file onto SAP.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Aug 2005 04:58:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-bdcs-and-flat-files/m-p/957798#M66694</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-08-02T04:58:43Z</dc:date>
    </item>
    <item>
      <title>Re: Help with BDCs and flat files.....</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-bdcs-and-flat-files/m-p/957799#M66695</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Anybody??&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Aug 2005 05:54:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-with-bdcs-and-flat-files/m-p/957799#M66695</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-08-02T05:54:57Z</dc:date>
    </item>
  </channel>
</rss>

