Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Uploading EXCEL file into Internal Table Using GUI_UPLOAD

Former Member
0 Likes
13,090

Can any one please give me an example use of FM "GUI_UPLOAD" which to upload a EXCEL file????? (not .txt)

10 REPLIES 10
Read only

Former Member
0 Likes
2,334

yes we can , for this FM GUI_UPLOAD

use FILETYPE = 'DAT'

Read only

Former Member
0 Likes
2,334

Hi Wizi,

Welcome to SCN

Please Search in SCN before Posting

check below example,

for excel to internal table try this function module,


CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
     EXPORTING
*   I_FIELD_SEPERATOR          = ','
      i_line_header              = p_head
       i_tab_raw_data             = it_raw
       i_filename                 = p_upl
     TABLES
       i_tab_converted_data       = t_indata
    EXCEPTIONS
      conversion_failed          = 1
      OTHERS                     = 2

Edited by: suresh suresh on Aug 4, 2009 3:17 PM

Read only

Former Member
0 Likes
2,334

Use one of the below FM

TEXT_CONVERT_XLS_TO_SAP

ALSM_EXCEL_TO_INTERNAL_TABLE

Read only

Former Member
0 Likes
2,334

Dear chenna,

tnx 4 your prompt reply.... but it gives me a weird output with lot of symbols.

others - apreciate your response. but i spesifically asked for FM "GUI_UPLOAD".... pls help me with it if you can.

cheers

Read only

0 Likes
2,334

Try in this way

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

FILENAME = tfile

FILETYPE = 'ASC'

TABLES

DATA_TAB = your internal table to store the data

endif.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,334

Use the forum search option [GUI_UPLOAD FOR EXCEL|https://forums.sdn.sap.com/search.jspa?threadID=&q=GUI_UPLOADFOREXCEL&objID=c42&dateRange=all&numResults=15&rankBy=10001]) or sdn wiki/code gallery ([UPLOAD EXCEL|https://wiki.sdn.sap.com/wiki/dosearchsite.action?searchQuery.queryString=upload+Excel&searchQuery.spaceKey=conf_global]) - Same question already answered many time

GUI_UPLOAD doesnt perform such conversion (Excel, Word, PDF) and wont give you a suitable result, use one of the FM mentioned above or [office integration|http://help.sap.com/saphelp_47x200/helpdata/en/21/b53138e1ba11d2bdbe080009b4534c/frameset.htm] or OLE or convert your Excel sheet to a simpler format : txt, csv, xml.

Regards,

Raymond

Read only

Former Member
0 Likes
2,334

subhajit - it says "cannot interpret data in file" when i change the filetype into "ASC".

Raymond - okey mate thanx. i thought i could use "GUI_UPLOAD" for excel files as well.

thanx for all your answers.

cheers

anushka

Edited by: wizkid0319 on Aug 6, 2009 12:33 PM

Read only

Former Member
0 Likes
2,334

Hi,

Refer to the given code:

DATA: lv_filetype(10) TYPE c,

lv_gui_sep TYPE c,

lv_file_name TYPE string.

lv_filetype = 'ASC'.

lv_gui_sep = 'X'.

lv_file_name = pa_dfile. "file path

  • FM call to upload file

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = lv_file_name

filetype = lv_filetype

has_field_separator = lv_gui_sep

TABLES

data_tab = gi_itab.

The file should be a tab delimited file. this will work only for that.

Regards,

Rajesh kumar

Read only

0 Likes
2,334

rajesh....

basically u r asking me to use a simple .TXT , .CSV .... kind of a file to upload rather than a EXCEL file rite???

but what i have is a EXCEL file.

If it is possible to do for a EXCEL file as well pls let me know?????

or else is it really impossible to do it for a EXCEL file using FM "GUI_UPLOAD" ????

cheers

anushka

Read only

Former Member
0 Likes
2,334

Hi Anushka,

No need to use GUI_UPLOAD as it will not solve your purpose, use the below code, it will work for sure.

You can use the below code to upload excel into internal table



  DATA: lv_file_name TYPE rlgrap-filename.

  CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
      i_line_header        = ''
      i_tab_raw_data       = tb_file_data
      i_filename           = lv_file_name<file name>
    TABLES
      i_tab_converted_data = <internal table with data>
    EXCEPTIONS
      conversion_failed    = 1
      OTHERS               = 2.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

Regards,

Manish