<?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: Excel File Upload in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/excel-file-upload/m-p/2825442#M661050</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;/P&gt;&lt;P&gt;use the fun module&lt;/P&gt;&lt;P&gt;ALSM_EXCEL_TO_INTERNAL_TABLE&lt;/P&gt;&lt;P&gt;and give that Excel file name&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward if useful&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Anji&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 20 Sep 2007 08:48:48 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-09-20T08:48:48Z</dc:date>
    <item>
      <title>Excel File Upload</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/excel-file-upload/m-p/2825441#M661049</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; I have an Excel file to upload. In that Excel 3 sheets are there, i want to Upload data only from the &amp;lt;b&amp;gt;2nd sheet&amp;lt;/b&amp;gt;.&lt;/P&gt;&lt;P&gt; How to do this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Sep 2007 08:46:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/excel-file-upload/m-p/2825441#M661049</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-20T08:46:39Z</dc:date>
    </item>
    <item>
      <title>Re: Excel File Upload</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/excel-file-upload/m-p/2825442#M661050</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;/P&gt;&lt;P&gt;use the fun module&lt;/P&gt;&lt;P&gt;ALSM_EXCEL_TO_INTERNAL_TABLE&lt;/P&gt;&lt;P&gt;and give that Excel file name&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward if useful&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Anji&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Sep 2007 08:48:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/excel-file-upload/m-p/2825442#M661050</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-20T08:48:48Z</dc:date>
    </item>
    <item>
      <title>Re: Excel File Upload</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/excel-file-upload/m-p/2825443#M661051</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to upload the Data only  from the &amp;lt;b&amp;gt;SECOND sheet&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Sep 2007 08:50:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/excel-file-upload/m-p/2825443#M661051</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-20T08:50:23Z</dc:date>
    </item>
    <item>
      <title>Re: Excel File Upload</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/excel-file-upload/m-p/2825444#M661052</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Gopi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the code to upload data from more than one sheet&lt;/P&gt;&lt;P&gt;I guess you could just comment the part for the first sheet to meet your requirement&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Report  ZKRIS_EXCELUPLOAD_2SHEETS
*&amp;amp;
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;
*&amp;amp;
*&amp;amp;---------------------------------------------------------------------*

report  zkris_excelupload_2sheets.


*      value of excel-cell
types: ty_d_itabvalue             type alsmex_tabline-value,
*      internal table containing the excel data
       ty_t_itab                  type alsmex_tabline   occurs 0,

*      line type of sender table
       begin of ty_s_senderline,
         line(4096)               type c,
       end of ty_s_senderline,
*      sender table
       ty_t_sender                type ty_s_senderline  occurs 0.

*

constants:  gc_esc              value '"'.
include lalsmexf01.
type-pools ole2.

start-of-selection.

  parameters: filename like rlgrap-filename.
  parameters: st_rw_s1 type i.
  parameters: st_cl_s1 type i.
  parameters: st_rw_s2 type i.
  parameters: st_cl_s2 type i.
  parameters: ed_rw_s1 type i.
  parameters: ed_cl_s1 type i.
  parameters: ed_rw_s2 type i.
  parameters: ed_cl_s2 type i.

  data: it_data1 type ty_t_itab.
  data: it_data2 type ty_t_itab.

  data: it_data_wa like line of it_data1.





* DATA DECLARATION

  data: excel_tab type ty_t_sender,
  excel_tab1 type ty_t_sender.

  data: ld_separator type c.
  data: application type ole2_object,
  workbook type ole2_object,
  sheet type ole2_object,
  range type ole2_object,
  worksheet type ole2_object.
  data: h_cell type ole2_object,
  h_cell1 type ole2_object.
  data: ld_rc type i.

* MESSAGE DEFINATION

  define m_message.
    case sy-subrc.
      when 0.
      when 1.
        message id sy-msgid type sy-msgty number sy-msgno
        with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      when others. raise upload_ole.
    endcase.
  end-of-definition.


* PARAMETER CHECK

  if st_rw_s1 &amp;gt; ed_rw_s1.
    raise inconsistent_parameters.
  endif.

  if st_cl_s1 &amp;gt; ed_cl_s1.
    raise inconsistent_parameters.
  endif.

  if st_rw_s2 &amp;gt; ed_rw_s2.
    raise inconsistent_parameters.
  endif.

  if st_cl_s2 &amp;gt; ed_cl_s2.
    raise inconsistent_parameters.
  endif.


  class cl_abap_char_utilities definition load.
  ld_separator = cl_abap_char_utilities=&amp;gt;horizontal_tab.

* OPENING EXCEL FILE
  if application-header = space or application-handle = -1.
    create object application 'Excel.Application'.
    m_message.
  endif.
  call method of application 'Workbooks' = workbook.
  m_message.
  call method of application 'Workbooks' = workbook.
  m_message.
  call method of workbook 'Open' exporting #1 = filename.
  m_message.
  call method of application 'Worksheets' = sheet exporting #1 = 1.
  m_message.
  call method of application 'Worksheets' = sheet exporting #1 = 1.
  m_message.
  call method of sheet 'Activate'.
  m_message.
  get property of application 'ACTIVESHEET' = sheet.
  m_message.

* MARKING OF WHOLE SPREADSHEET
  call method of sheet 'Cells' = h_cell
    exporting #1 = st_rw_s1 #2 = st_cl_s1.
  m_message.
  call method of sheet 'Cells' = h_cell1
    exporting #1 = ed_rw_s1 #2 = ed_cl_s1.
  m_message.

  call method of sheet 'RANGE' = range
    exporting #1 = h_cell #2 = h_cell1.
  m_message.
  call method of range 'SELECT'.
  m_message.

* Copy marked area (SHEET1) into Clippboard

  call method of range 'COPY'.
  m_message.

* Read clipboard into ABAP

  call method cl_gui_frontend_services=&amp;gt;clipboard_import
  importing
  data = excel_tab
  exceptions
  cntl_error = 1
* ERROR_NO_GUI = 2
* NOT_SUPPORTED_BY_GUI = 3
  others = 4
  .
  if sy-subrc &amp;lt;&amp;gt; 0.
    message a037(alsmex).
  endif.

  perform separated_to_intern_convert tables excel_tab it_data1
  using ld_separator.

* Clear the clipboard

  refresh excel_tab.
  call method cl_gui_frontend_services=&amp;gt;clipboard_export
  importing
  data = excel_tab
  changing
  rc = ld_rc
  exceptions
  cntl_error = 1
* ERROR_NO_GUI = 2
* NOT_SUPPORTED_BY_GUI = 3
  others = 4
  .

* Working in Second Excel Work Sheet

  call method of application 'Worksheets' = sheet exporting #1 = 2.
  m_message.
  call method of sheet 'Activate'.
  m_message.
  get property of application 'ACTIVESHEET' = sheet.
  m_message.
* Mark Sheet2

  call method of sheet 'Cells' = h_cell
    exporting #1 = st_rw_s2 #2 = st_cl_s2.
  m_message.
  call method of sheet 'Cells' = h_cell1
    exporting #1 = ed_rw_s2 #2 = ed_cl_s2.
  m_message.

  call method of sheet 'RANGE' = range
    exporting #1 = h_cell #2 = h_cell1.
  m_message.
  call method of range 'SELECT'.
  m_message.

* Copy Marked Area (Sheet2) into Clippboard

  call method of range 'COPY'.
  m_message.

* Read Clipboard into ABAP

  call method cl_gui_frontend_services=&amp;gt;clipboard_import
  importing
  data = excel_tab1
  exceptions
  cntl_error = 1
* ERROR_NO_GUI = 2
* NOT_SUPPORTED_BY_GUI = 3
  others = 4
  .
  if sy-subrc &amp;lt;&amp;gt; 0.
    message a037(alsmex).
  endif.

  perform separated_to_intern_convert tables excel_tab1 it_data2
  using ld_separator.

* Clear Clipboard

  refresh excel_tab.
  call method cl_gui_frontend_services=&amp;gt;clipboard_export
  importing
  data = excel_tab1
  changing
  rc = ld_rc
  exceptions
  cntl_error = 1
* ERROR_NO_GUI = 2
* NOT_SUPPORTED_BY_GUI = 3
  others = 4
* Leaving Application
  .
  call method of application 'QUIT'.
  m_message.

  free object application.
  m_message.


  loop at it_data1 into it_data_wa.
    write:/ it_data_wa.
  endloop.

  skip 3.

  loop at it_data2 into it_data_wa.
    write:/ it_data_wa.
  endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Sep 2007 08:58:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/excel-file-upload/m-p/2825444#M661052</guid>
      <dc:creator>former_member189059</dc:creator>
      <dc:date>2007-09-20T08:58:44Z</dc:date>
    </item>
    <item>
      <title>Re: Excel File Upload</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/excel-file-upload/m-p/2825445#M661053</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi, &lt;/P&gt;&lt;P&gt;Function module: ALSM_EXCEL_TO_INTERNAL_TABLE&lt;/P&gt;&lt;P&gt;This FM only catch data which sheet is active.  That means only one sheet will be read by this function module.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For your requirement,  I suggest that you need write coding manually to upload your excel file.&lt;/P&gt;&lt;P&gt;key statement: CREATE OBJECT &lt;/P&gt;&lt;P&gt;                       SET PROPERTY OF obj p = f. &lt;/P&gt;&lt;P&gt;                       GET PROPERTY OF obj p = f.&lt;/P&gt;&lt;P&gt;                       CALL METHOD OF obj m. &lt;/P&gt;&lt;P&gt;                       FREE OBJECT &lt;/P&gt;&lt;P&gt;Actually, This is same concept as function moduleALSM_EXCEL_TO_INTERNAL_TABLE.(They are all belong to OLE programming) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But you can customize your OLE coding in your program.&lt;/P&gt;&lt;P&gt;you can use the functionality of Macro Recording in EXCEL to generate OLE coding(This seems like BDC recording in SAP).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this will help you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Sep 2007 09:05:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/excel-file-upload/m-p/2825445#M661053</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-20T09:05:25Z</dc:date>
    </item>
  </channel>
</rss>

