<?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: How to upload an excel file using ABAP. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-upload-an-excel-file-using-abap/m-p/3175951#M755828</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="http://diocio.wordpress.com/2007/02/12/sap-upload-excel-document-into-internal-table/" target="test_blank"&gt;http://diocio.wordpress.com/2007/02/12/sap-upload-excel-document-into-internal-table/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;check the link&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPES: Begin of t_record,&lt;/P&gt;&lt;P&gt;name1 like itab-value,&lt;/P&gt;&lt;P&gt;name2 like itab-value,&lt;/P&gt;&lt;P&gt;age   like itab-value,&lt;/P&gt;&lt;P&gt;End of t_record.&lt;/P&gt;&lt;P&gt;DATA: it_record type standard table of t_record initial size 0,&lt;/P&gt;&lt;P&gt;wa_record type t_record.&lt;/P&gt;&lt;P&gt;DATA: gd_currentrow type i.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Selection Screen Declaration&lt;/P&gt;&lt;P&gt;*&amp;#151;&amp;#151;&amp;#151;&amp;#151;&amp;#151;&amp;#151;&amp;#151;&amp;#151;&amp;#151;-&lt;/P&gt;&lt;P&gt;PARAMETER p_infile like rlgrap-filename.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;*START OF SELECTION&lt;/P&gt;&lt;P&gt;call function &amp;#145;ALSM_EXCEL_TO_INTERNAL_TABLE&amp;#146;&lt;/P&gt;&lt;P&gt;exporting&lt;/P&gt;&lt;P&gt;filename                = p_infile&lt;/P&gt;&lt;P&gt;i_begin_col             = &amp;#145;1&amp;amp;#8242;&lt;/P&gt;&lt;P&gt;i_begin_row             = &amp;#145;2&amp;amp;#8242;  &amp;#147;Do not require headings&lt;/P&gt;&lt;P&gt;i_end_col               = &amp;#145;14&amp;amp;#8242;&lt;/P&gt;&lt;P&gt;i_end_row               = &amp;#145;31&amp;amp;#8242;&lt;/P&gt;&lt;P&gt;tables&lt;/P&gt;&lt;P&gt;intern                  = itab&lt;/P&gt;&lt;P&gt;exceptions&lt;/P&gt;&lt;P&gt;inconsistent_parameters = 1&lt;/P&gt;&lt;P&gt;upload_ole              = 2&lt;/P&gt;&lt;P&gt;others                  = 3.&lt;/P&gt;&lt;P&gt;if sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;message e010(zz) with text-001. &amp;#147;Problem uploading Excel Spreadsheet&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Sort table by rows and colums&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;sort itab by row col.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Get first row retrieved&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;read table itab index 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Set first row retrieved to current row&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;gd_currentrow = itab-row.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  Reset values for next row&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;if itab-row ne gd_currentrow.&lt;/P&gt;&lt;P&gt;append wa_record to it_record.&lt;/P&gt;&lt;P&gt;clear wa_record.&lt;/P&gt;&lt;P&gt;gd_currentrow = itab-row.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;case itab-col.&lt;/P&gt;&lt;P&gt;when &amp;#145;0001&amp;amp;#8242;.                              &amp;#147;First name&lt;/P&gt;&lt;P&gt;wa_record-name1 = itab-value.&lt;/P&gt;&lt;P&gt;when &amp;#145;0002&amp;amp;#8242;.                              &amp;#147;Surname&lt;/P&gt;&lt;P&gt;wa_record-name2 = itab-value.&lt;/P&gt;&lt;P&gt;when &amp;#145;0003&amp;amp;#8242;.                              &amp;#147;Age&lt;/P&gt;&lt;P&gt;wa_record-age   = itab-value.&lt;/P&gt;&lt;P&gt;endcase.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;append wa_record to it_record.&lt;/P&gt;&lt;P&gt;*!! Excel data is now contained within the internal table IT_RECORD&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Display report data for illustration purposes&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;loop at it_record into wa_record.&lt;/P&gt;&lt;P&gt;write:/     sy-vline,&lt;/P&gt;&lt;P&gt;(10) wa_record-name1, sy-vline,&lt;/P&gt;&lt;P&gt;(10) wa_record-name2, sy-vline,&lt;/P&gt;&lt;P&gt;(10) wa_record-age, sy-vline.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 07 Dec 2007 05:39:30 GMT</pubDate>
    <dc:creator>former_member195698</dc:creator>
    <dc:date>2007-12-07T05:39:30Z</dc:date>
    <item>
      <title>How to upload an excel file using ABAP.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-upload-an-excel-file-using-abap/m-p/3175950#M755827</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;Can anyone please help me in understanding how to upload an excel file using ABAP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Dec 2007 05:36:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-upload-an-excel-file-using-abap/m-p/3175950#M755827</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-12-07T05:36:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to upload an excel file using ABAP.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-upload-an-excel-file-using-abap/m-p/3175951#M755828</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="http://diocio.wordpress.com/2007/02/12/sap-upload-excel-document-into-internal-table/" target="test_blank"&gt;http://diocio.wordpress.com/2007/02/12/sap-upload-excel-document-into-internal-table/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;check the link&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPES: Begin of t_record,&lt;/P&gt;&lt;P&gt;name1 like itab-value,&lt;/P&gt;&lt;P&gt;name2 like itab-value,&lt;/P&gt;&lt;P&gt;age   like itab-value,&lt;/P&gt;&lt;P&gt;End of t_record.&lt;/P&gt;&lt;P&gt;DATA: it_record type standard table of t_record initial size 0,&lt;/P&gt;&lt;P&gt;wa_record type t_record.&lt;/P&gt;&lt;P&gt;DATA: gd_currentrow type i.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Selection Screen Declaration&lt;/P&gt;&lt;P&gt;*&amp;#151;&amp;#151;&amp;#151;&amp;#151;&amp;#151;&amp;#151;&amp;#151;&amp;#151;&amp;#151;-&lt;/P&gt;&lt;P&gt;PARAMETER p_infile like rlgrap-filename.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;*START OF SELECTION&lt;/P&gt;&lt;P&gt;call function &amp;#145;ALSM_EXCEL_TO_INTERNAL_TABLE&amp;#146;&lt;/P&gt;&lt;P&gt;exporting&lt;/P&gt;&lt;P&gt;filename                = p_infile&lt;/P&gt;&lt;P&gt;i_begin_col             = &amp;#145;1&amp;amp;#8242;&lt;/P&gt;&lt;P&gt;i_begin_row             = &amp;#145;2&amp;amp;#8242;  &amp;#147;Do not require headings&lt;/P&gt;&lt;P&gt;i_end_col               = &amp;#145;14&amp;amp;#8242;&lt;/P&gt;&lt;P&gt;i_end_row               = &amp;#145;31&amp;amp;#8242;&lt;/P&gt;&lt;P&gt;tables&lt;/P&gt;&lt;P&gt;intern                  = itab&lt;/P&gt;&lt;P&gt;exceptions&lt;/P&gt;&lt;P&gt;inconsistent_parameters = 1&lt;/P&gt;&lt;P&gt;upload_ole              = 2&lt;/P&gt;&lt;P&gt;others                  = 3.&lt;/P&gt;&lt;P&gt;if sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;message e010(zz) with text-001. &amp;#147;Problem uploading Excel Spreadsheet&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Sort table by rows and colums&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;sort itab by row col.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Get first row retrieved&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;read table itab index 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Set first row retrieved to current row&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;gd_currentrow = itab-row.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  Reset values for next row&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;if itab-row ne gd_currentrow.&lt;/P&gt;&lt;P&gt;append wa_record to it_record.&lt;/P&gt;&lt;P&gt;clear wa_record.&lt;/P&gt;&lt;P&gt;gd_currentrow = itab-row.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;case itab-col.&lt;/P&gt;&lt;P&gt;when &amp;#145;0001&amp;amp;#8242;.                              &amp;#147;First name&lt;/P&gt;&lt;P&gt;wa_record-name1 = itab-value.&lt;/P&gt;&lt;P&gt;when &amp;#145;0002&amp;amp;#8242;.                              &amp;#147;Surname&lt;/P&gt;&lt;P&gt;wa_record-name2 = itab-value.&lt;/P&gt;&lt;P&gt;when &amp;#145;0003&amp;amp;#8242;.                              &amp;#147;Age&lt;/P&gt;&lt;P&gt;wa_record-age   = itab-value.&lt;/P&gt;&lt;P&gt;endcase.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;append wa_record to it_record.&lt;/P&gt;&lt;P&gt;*!! Excel data is now contained within the internal table IT_RECORD&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Display report data for illustration purposes&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;loop at it_record into wa_record.&lt;/P&gt;&lt;P&gt;write:/     sy-vline,&lt;/P&gt;&lt;P&gt;(10) wa_record-name1, sy-vline,&lt;/P&gt;&lt;P&gt;(10) wa_record-name2, sy-vline,&lt;/P&gt;&lt;P&gt;(10) wa_record-age, sy-vline.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Dec 2007 05:39:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-upload-an-excel-file-using-abap/m-p/3175951#M755828</guid>
      <dc:creator>former_member195698</dc:creator>
      <dc:date>2007-12-07T05:39:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to upload an excel file using ABAP.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-upload-an-excel-file-using-abap/m-p/3175952#M755829</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;&lt;/P&gt;&lt;P&gt;  USe FM  ALSM_EXCEL_TO_INTERNAL_TABLE&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Prashant&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Dec 2007 05:39:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-upload-an-excel-file-using-abap/m-p/3175952#M755829</guid>
      <dc:creator>former_member386202</dc:creator>
      <dc:date>2007-12-07T05:39:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to upload an excel file using ABAP.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-upload-an-excel-file-using-abap/m-p/3175953#M755830</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;to upload an excel file into internal table use these function modules :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to get the name of excel file from system use : &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPES : BEGIN OF STRUCT,&lt;/P&gt;&lt;P&gt;TEXT(1000) TYPE C,&lt;/P&gt;&lt;P&gt;END OF STRUCT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : v_row type i,&lt;/P&gt;&lt;P&gt;v_col type i.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: IFILE LIKE RLGRAP-FILENAME.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA : ITAB_TEXT TYPE STANDARD TABLE OF STRUCT WITH HEADER LINE,&lt;/P&gt;&lt;P&gt;itab_upld type standard table of ALSMEX_TABLINE with header line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'KD_GET_FILENAME_ON_F4'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;PROGRAM_NAME = SYST-REPID&lt;/P&gt;&lt;P&gt;DYNPRO_NUMBER = SYST-DYNNR&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;FIELD_NAME =&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;STATIC = ' X'&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;MASK = '*.txt'&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;CHANGING&lt;/P&gt;&lt;P&gt;FILE_NAME = IFILE&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;MASK_TOO_LONG = 1&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;OTHERS = 2&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;To upload the data form excel file use this funcn module : &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;FILENAME = IFILE&lt;/P&gt;&lt;P&gt;I_BEGIN_COL = 1&lt;/P&gt;&lt;P&gt;I_BEGIN_ROW = 2&lt;/P&gt;&lt;P&gt;I_END_COL = 47&lt;/P&gt;&lt;P&gt;I_END_ROW = 65536&lt;/P&gt;&lt;P&gt;TABLES&lt;/P&gt;&lt;P&gt;INTERN = ITAB_UPLD&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;INCONSISTENT_PARAMETERS = 1&lt;/P&gt;&lt;P&gt;UPLOAD_OLE = 2&lt;/P&gt;&lt;P&gt;OTHERS = 3.&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;*Sort table itab_upld by rows and columns.&lt;/P&gt;&lt;P&gt;SORT ITAB_UPLD[] BY ROW COL.&lt;/P&gt;&lt;P&gt;APPEND ITAB_TEXT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT ITAB_UPLD.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AT NEW ROW.&lt;/P&gt;&lt;P&gt;MOVE ITAB_UPLD-VALUE TO ITAB_TEXT.&lt;/P&gt;&lt;P&gt;V_ROW = V_ROW + 1.&lt;/P&gt;&lt;P&gt;V_COL = 1.&lt;/P&gt;&lt;P&gt;IF SY-TABIX NE 1.&lt;/P&gt;&lt;P&gt;APPEND ITAB_TEXT.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDAT. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can also refer to this link&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_thread" href="https://community.sap.com/" __jive_macro_name="thread" modifiedtitle="true" __default_attr="416259"&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Dec 2007 05:42:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-upload-an-excel-file-using-abap/m-p/3175953#M755830</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-12-07T05:42:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to upload an excel file using ABAP.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-upload-an-excel-file-using-abap/m-p/3175954#M755831</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi WASIM The below CODE should help you with ur query,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPE-POOLS: truxs.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;DATA: i_text_data TYPE truxs_t_text_data,&lt;/P&gt;&lt;P&gt;v_filename_string TYPE string.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;DATA: BEGIN OF itab OCCURS 0,&lt;/P&gt;&lt;P&gt;Name(30),&lt;/P&gt;&lt;P&gt;Phone(15),&lt;/P&gt;&lt;P&gt;Fax(500).&lt;/P&gt;&lt;P&gt;DATA: END OF itab.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;PARAMETERS: p_file LIKE rlgrap-filename.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;START-OF-SELECTION.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;v_filename_string = p_file.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;CALL FUNCTION 'GUI_UPLOAD'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;filename = v_filename_string&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;/UL&gt;&lt;P&gt;dat_mode = ''&lt;/P&gt;&lt;UL&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 = i_text_data&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;file_open_error = 1&lt;/P&gt;&lt;P&gt;file_read_error = 2&lt;/P&gt;&lt;P&gt;no_batch = 3&lt;/P&gt;&lt;P&gt;gui_refuse_filetransfer = 4&lt;/P&gt;&lt;P&gt;invalid_type = 5&lt;/P&gt;&lt;P&gt;no_authority = 6&lt;/P&gt;&lt;P&gt;unknown_error = 7&lt;/P&gt;&lt;P&gt;bad_data_format = 8&lt;/P&gt;&lt;P&gt;header_not_allowed = 9&lt;/P&gt;&lt;P&gt;separator_not_allowed = 10&lt;/P&gt;&lt;P&gt;header_too_long = 11&lt;/P&gt;&lt;P&gt;unknown_dp_error = 12&lt;/P&gt;&lt;P&gt;access_denied = 13&lt;/P&gt;&lt;P&gt;dp_out_of_memory = 14&lt;/P&gt;&lt;P&gt;disk_full = 15&lt;/P&gt;&lt;P&gt;dp_timeout = 16&lt;/P&gt;&lt;P&gt;OTHERS = 17.&lt;/P&gt;&lt;P&gt;IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno&lt;/P&gt;&lt;P&gt;WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;i_field_seperator = 'X'&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;I_LINE_HEADER =&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;i_tab_raw_data = i_text_data&lt;/P&gt;&lt;P&gt;i_filename = p_file&lt;/P&gt;&lt;P&gt;TABLES&lt;/P&gt;&lt;P&gt;i_tab_converted_data = itab&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;conversion_failed = 1&lt;/P&gt;&lt;P&gt;OTHERS = 2.&lt;/P&gt;&lt;P&gt;IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno&lt;/P&gt;&lt;P&gt;WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.&lt;/P&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;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this is a sample code that uploads a excel file using GUI_UPLOAD, but uses another function module to convert that uploaded data into an internal table..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Kindly Reward points if you found the reply helpful&amp;lt;/b&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;CHAITANYA.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Dec 2007 05:43:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-upload-an-excel-file-using-abap/m-p/3175954#M755831</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-12-07T05:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to upload an excel file using ABAP.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-upload-an-excel-file-using-abap/m-p/3175955#M755832</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;check this link.&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapdevelopment.co.uk/file/file_upexcel.htm" target="test_blank"&gt;http://www.sapdevelopment.co.uk/file/file_upexcel.htm&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Dec 2007 05:51:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-upload-an-excel-file-using-abap/m-p/3175955#M755832</guid>
      <dc:creator>former_member188829</dc:creator>
      <dc:date>2007-12-07T05:51:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to upload an excel file using ABAP.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-upload-an-excel-file-using-abap/m-p/3175956#M755833</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;see this program in this &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EXCEL TO INTERNAL TABLE AND THEN TO APPLICATION SERVER &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT  ZSD_EXCEL_INT_APP.

parameter: file_nm type localfile.

types : begin of it_tab1,
        f1(20),
        f2(40),
        f3(20),
       end of it_tab1.


data : it_tab type table of ALSMEX_TABLINE with header line,
       file type rlgrap-filename.

data : it_tab2 type it_tab1 occurs 1,
       wa_tab2 type it_tab1,
       w_message(100)  TYPE c.


at selection-screen on value-request for file_nm.

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
 EXPORTING
*   PROGRAM_NAME        = SYST-REPID
*   DYNPRO_NUMBER       = SYST-DYNNR
*   FIELD_NAME          = ' '
   STATIC              = 'X'
*   MASK                = ' '
  CHANGING
   file_name           = file_nm
 EXCEPTIONS
   MASK_TOO_LONG       = 1
   OTHERS              = 2
          .
IF sy-subrc &amp;lt;&amp;gt; 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.


start-of-selection.

refresh it_tab2[].clear wa_tab2.

file = file_nm.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
  EXPORTING
    filename                      = file
    i_begin_col                   = '1'
    i_begin_row                   =  '1'
    i_end_col                     = '10'
    i_end_row                     = '35'
  tables
    intern                        = it_tab
 EXCEPTIONS
   INCONSISTENT_PARAMETERS       = 1
   UPLOAD_OLE                    = 2
   OTHERS                        = 3
          .
IF sy-subrc &amp;lt;&amp;gt; 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

loop at it_tab.

  case it_tab-col.

   when '002'.

    wa_tab2-f1 = it_tab-value.

   when '004'.

    wa_tab2-f2 = it_tab-value.

  when '008'.

    wa_tab2-f3 = it_tab-value.

 endcase.

 at end of row.

  append wa_tab2 to it_tab2.
 clear wa_tab2.
  endat.

endloop.

data : p_file TYPE  rlgrap-filename value 'TEST3.txt'.


OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
*--- Display error messages if any.
  IF sy-subrc NE 0.
    MESSAGE e001(zsd_mes).
    EXIT.
  ELSE.

*---Data is downloaded to the application server file path
    LOOP AT it_tab2 INTO wa_tab2.
      TRANSFER wa_tab2 TO p_file.
    ENDLOOP.
  ENDIF.

*--Close the Application server file (Mandatory).
  CLOSE DATASET p_file.

 loop at it_tab2 into wa_tab2.

  write : / wa_tab2-f1,wa_tab2-f2,wa_tab2-f3.

 endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Dec 2007 05:52:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-upload-an-excel-file-using-abap/m-p/3175956#M755833</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-12-07T05:52:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to upload an excel file using ABAP.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-upload-an-excel-file-using-abap/m-p/3175957#M755834</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;By using the standard function ALSM_EXCEL_TO_INTERNAL_TABLE, you can import most Excel documents into an SAP internal table. Please note that this code is set up for spreadsheets up to 9999 rows. If you need more, use a 'DO' statement to loop through the Excel file in 9999 row segments until all is retreived&lt;/P&gt;&lt;P&gt;The code runs on 4.6B.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: &lt;/P&gt;&lt;P&gt;  DATA LIKE ALSMEX_TABLINE OCCURS 100,&lt;/P&gt;&lt;P&gt;"ALSM_EXCEL_TO_INTERNAL_TABLE structure&lt;/P&gt;&lt;P&gt;  BCOL TYPE I VALUE 1, &lt;/P&gt;&lt;P&gt;"This can be any Column in your &lt;/P&gt;&lt;P&gt;"   spreadsheet where you want to start &lt;/P&gt;&lt;P&gt;"   importing data&lt;/P&gt;&lt;P&gt;  BROW TYPE I VALUE 1, &lt;/P&gt;&lt;P&gt;"This can be any Row in your &lt;/P&gt;&lt;P&gt;"   spreadsheet where you want to start&lt;/P&gt;&lt;P&gt;"   importing data&lt;/P&gt;&lt;P&gt;  ECOL TYPE I VALUE 9, &lt;/P&gt;&lt;P&gt;"This can be any Column in your &lt;/P&gt;&lt;P&gt;"    spreadsheet where you want to stop &lt;/P&gt;&lt;P&gt;"    importing data&lt;/P&gt;&lt;P&gt;  EROW TYPE I VALUE 9999. &lt;/P&gt;&lt;P&gt;"This can be any Row in your &lt;/P&gt;&lt;P&gt;"    spreadsheet where you want to stop &lt;/P&gt;&lt;P&gt;"    importing data&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"There is little hurt to enter a larger &lt;/P&gt;&lt;P&gt;"number for the upper limit of the rows &lt;/P&gt;&lt;P&gt;"or columns. It may take a few extra &lt;/P&gt;&lt;P&gt;"seconds to import, but only those &lt;/P&gt;&lt;P&gt;"fields who's values are not equal &lt;/P&gt;&lt;P&gt;"to ' ', space, will be imported.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: UPFILE(128) VALUE 'C:/'.&lt;/P&gt;&lt;P&gt;"You should provide the user a popup &lt;/P&gt;&lt;P&gt;" window to allow them the option to&lt;/P&gt;&lt;P&gt;" select a file from their PC or network&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"Call to import Excel document&lt;/P&gt;&lt;P&gt;  CALL FUNCTION &lt;/P&gt;&lt;P&gt;      'ALSM_EXCEL_TO_INTERNAL_TABLE'&lt;/P&gt;&lt;P&gt;    EXPORTING&lt;/P&gt;&lt;P&gt;     FILENAME     = UPFILE&lt;/P&gt;&lt;P&gt;     I_BEGIN_COL  = BCOL&lt;/P&gt;&lt;P&gt;     I_BEGIN_ROW  = BROW&lt;/P&gt;&lt;P&gt;     I_END_COL    = ECOL&lt;/P&gt;&lt;P&gt;     I_END_ROW    = EROW&lt;/P&gt;&lt;P&gt;    TABLES &lt;/P&gt;&lt;P&gt;     INTERN       = DATA&lt;/P&gt;&lt;P&gt;    EXCEPTIONS&lt;/P&gt;&lt;P&gt;     INCONSISTENT_PARAMETERS = 1&lt;/P&gt;&lt;P&gt;     UPLOAD_OLE              = 2&lt;/P&gt;&lt;P&gt;     OTHERS                  = 3.&lt;/P&gt;&lt;P&gt;  IF SY-SUBRC &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;    MESSAGE ID SY-MSGID TYPE SY-MSGTY &lt;/P&gt;&lt;P&gt;            NUMBER SY-MSGNO&lt;/P&gt;&lt;P&gt;            WITH SY-MSGV1 SY-MSGV2 &lt;/P&gt;&lt;P&gt;                 SY-MSGV3 SY-MSGV4.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Award points if found useful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Chandra Sekhar.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Dec 2007 07:04:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-upload-an-excel-file-using-abap/m-p/3175957#M755834</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-12-07T07:04:00Z</dc:date>
    </item>
  </channel>
</rss>

