<?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: function module to get data from files in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-to-get-data-from-files/m-p/5681647#M1291434</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Basic question i feel.Use gui_upload&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 30 May 2009 13:51:45 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-05-30T13:51:45Z</dc:date>
    <item>
      <title>function module to get data from files</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-to-get-data-from-files/m-p/5681646#M1291433</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi, can anyone tell me the function module to get data from any kind of file, be it a word document or excel sheet, or a plain text file ? i need to get the contents of the file and display them. And also do i need to convert it to a particular format while reading and displaying ? Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 30 May 2009 13:38:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-to-get-data-from-files/m-p/5681646#M1291433</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-30T13:38:00Z</dc:date>
    </item>
    <item>
      <title>Re: function module to get data from files</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-to-get-data-from-files/m-p/5681647#M1291434</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Basic question i feel.Use gui_upload&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 30 May 2009 13:51:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-to-get-data-from-files/m-p/5681647#M1291434</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-30T13:51:45Z</dc:date>
    </item>
    <item>
      <title>Re: function module to get data from files</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-to-get-data-from-files/m-p/5681648#M1291435</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;did that, but the contents i get are i think in another format, coz they are not in english, so if i have to convert them into another format for displaying then can you tell me a function module for converting it to another format ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 30 May 2009 13:54:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-to-get-data-from-files/m-p/5681648#M1291435</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-30T13:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: function module to get data from files</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-to-get-data-from-files/m-p/5681649#M1291436</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Hitesh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are number of FM's for resolving your issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;uplaod documents mayu be of .doc,.xls or .txt according to the ease we can select the FM's&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;FM for excel as it will have rows and columns&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;PARAMETER p_infile like rlgrap-filename.

call function u2018ALSM_EXCEL_TO_INTERNAL_TABLEu2019
exporting
filename                = p_infile
i_begin_col             = u20181u2032
i_begin_row             = u20182u2032  u201CDo not require headings
i_end_col               = u201814u2032
i_end_row               = u201831u2032
tables
intern                  = itab
exceptions
inconsistent_parameters = 1
upload_ole              = 2
others                  = 3.
if sy-subrc &amp;lt;&amp;gt; 0.
message e010(zz) with text-001. u201CProblem uploading Excel Spreadsheet
endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;PARAMETERS: p_file TYPE rlgrap-filename.

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

 EXPORTING

 i_line_header        = 'X'

 i_tab_raw_data       = it_raw

 i_filename           = p_file

 TABLES

 i_tab_converted_data = it_datatab[]

 EXCEPTIONS

 conversion_failed    = 1

 OTHERS               = 2.

 IF sy-subrc &amp;lt;&amp;gt; 0.

 *  key in some message

 ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;FM for text files as our friend suggested GUI_UPLOAD&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;PARAMETERS: p_file(80)
DEFAULT 'C:\Temp\Zexample.txt'.

CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = filename
* FILETYPE = 'ASC
has_field_separator = 'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
data_tab = i_tab
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 &amp;lt;&amp;gt; 0.
v_subrc = sy-subrc.
MESSAGE e899 WITH 'Your Error message.
ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope this helps&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and Regards&lt;/P&gt;&lt;P&gt;Srikanth.P&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: SRIKANTH P on May 30, 2009 8:58 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 30 May 2009 15:28:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-to-get-data-from-files/m-p/5681649#M1291436</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-30T15:28:00Z</dc:date>
    </item>
    <item>
      <title>Re: function module to get data from files</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-to-get-data-from-files/m-p/5681650#M1291437</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;use function module GUI_UPLOAD to get data from any source file while the source file is in presentation server.&lt;/P&gt;&lt;P&gt;read the data using this function module into a table type of string. then split the string accordingly by the given separator and display them in any way you want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but if the source file is in application server then use the following approach to read data in string format:&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;open dataset.&lt;/P&gt;&lt;P&gt;read dataset.&lt;/P&gt;&lt;P&gt;close dataset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Prinan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 30 May 2009 15:34:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-to-get-data-from-files/m-p/5681650#M1291437</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-30T15:34:36Z</dc:date>
    </item>
    <item>
      <title>Re: function module to get data from files</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-to-get-data-from-files/m-p/5681651#M1291438</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;Function module GUI_UPLOAD will works for you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;once the data pass into the internal table then you can display .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Aswarth&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 30 May 2009 18:06:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-to-get-data-from-files/m-p/5681651#M1291438</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-30T18:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: function module to get data from files</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-to-get-data-from-files/m-p/5681652#M1291439</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Hitesh Nangrani,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use the following function module to read a file and upload it to some internal table, inorder to use the data further.&lt;/P&gt;&lt;P&gt;I'll give you an example wherein theres a selection screen to select any file (word or excel) from ur PC and then upload it to an internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Example :&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Define a variable of type string to hold ur file name&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data : lv_file_name type string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt;SELECTION SCREEN ***&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;Selection Screen to take the file, where p_f_name is the parameter of type rlgrap-filename and it is&lt;/STRONG&gt; &lt;STRONG&gt;made mandatory &amp;amp; text-100 is a text field where u can give any description like "please input file path"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;selection-screen begin of block b1 with frame title text-100.&lt;/P&gt;&lt;P&gt;parameters : p_f_name like rlgrap-filename obligatory.&lt;/P&gt;&lt;P&gt;selection-screen end of block b1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt;AT SELECTION-SCREEN ***&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;at selection-screen on value-request for p_f_name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt;Function Module To Open The Input File Containing The Input Values ***&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;following function module will open the file, in IMPORTING give the parameter p_f_name, which has the&lt;/STRONG&gt; &lt;STRONG&gt;file path, it will open the file at that path i.e. the file u want&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;call function 'WS_FILENAME_GET'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;def_filename     = 'C:\test.xls'&lt;/P&gt;&lt;P&gt;def_path         = 'C:\'&lt;/P&gt;&lt;P&gt;mask             = ',&lt;STRONG&gt;.&lt;/STRONG&gt;,&lt;STRONG&gt;.&lt;/STRONG&gt;.'&lt;/P&gt;&lt;P&gt;mode             = 'O'          "O --&amp;gt; Open S --&amp;gt; Save&lt;/P&gt;&lt;P&gt;title            = 'OPEN'&lt;/P&gt;&lt;P&gt;IMPORTING&lt;/P&gt;&lt;P&gt;filename         = p_f_name&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;inv_winsys       = 1&lt;/P&gt;&lt;P&gt;no_batch         = 2&lt;/P&gt;&lt;P&gt;selection_cancel = 3&lt;/P&gt;&lt;P&gt;selection_error  = 4&lt;/P&gt;&lt;P&gt;others           = 5.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Assign the file path to the variable u had declared to hold the file name&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt;START-OF-SELECTION ***&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;start-of-selection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  lv_file_name = p_f_name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt;Function Module To Upload Input File To The Internal Table ***&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;following function module will read the file and transfer it data to the internal table&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;In FILENAME assign the filename variabe and in TABLES assign the internal table name in which u&lt;/STRONG&gt; &lt;STRONG&gt;want the file data to come&lt;/STRONG&gt;&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  = lv_file_name&lt;/P&gt;&lt;P&gt;filetype  = 'ASC'&lt;/P&gt;&lt;P&gt;has_field_separator   = 'X'&lt;/P&gt;&lt;P&gt;TABLES&lt;/P&gt;&lt;P&gt;data_tab  = lt_material_details.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;NOTE :&lt;/STRONG&gt;  See to it that ur internal table has all the fields that are there in ur excel sheet / word, so that the contents of file properly go into respective fields of internal table. otherwise there would be mis-matching of fields and data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this reply would help you...do let me knw if it worked...All The Best &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&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;Radhika&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 30 May 2009 18:24:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-to-get-data-from-files/m-p/5681652#M1291439</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-30T18:24:04Z</dc:date>
    </item>
    <item>
      <title>Re: function module to get data from files</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-to-get-data-from-files/m-p/5681653#M1291440</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks a lot everyone&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 30 May 2009 18:48:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-to-get-data-from-files/m-p/5681653#M1291440</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-30T18:48:02Z</dc:date>
    </item>
  </channel>
</rss>

