cancel
Showing results for 
Search instead for 
Did you mean: 

Upload a Excelsheet by using BSP application

Former Member
0 Kudos

Hi folks,

I want to upload an Excelsheet by using a Web Application.

Now initially I wanted to do, by using WDA. But then i get to know that, we can not use EXCEL file to upload data using WDA.( It has to be CSV or TXT).

So just want to know, wether it's possible to upload an Excels sheet using BSP, and If yes , could you please give me some more details about it's implementation.

Thanks

PG

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

I am showing MVC BSP application

In BSP view define field

<input type="file" .....  >

>

In MVC code

data: lv_fupld_data TYPE REF TO cl_htmlb_fileupload,
         lv_filename type string,
         lv_filecontent type xstring,
         conv TYPE REF TO CL_ABAP_CONV_IN_CE,
         ocontent type string,
         len      type i,
        lt_excel type table of tdline, .

**Upload file from View
lv_fupld_data ?= cl_htmlb_manager=>get_data( request = runtime->server->request name = 'fileupload' id = 'file').
**Identify file name
lv_filename = lv_fupld_data->FILE_NAME.
**Identify content
lv_filecontent = lv_fupld_data->FILE_CONTENT.
**Intiate container for BSP file content
conv = cl_abap_conv_in_ce=>create( input = lv_filecontent ).
**Read container
conv->read( IMPORTING data = ocontent len = len ). "length of the file
*Split string to row of  table
split ocontent at cl_abap_char_utilities=>cr_lf into table lt_excel .

LOOP AT lt_excel  ASSIGNING <row>.
*This for comma delimited , but you can do other delimintor "TAB,...
split <row> at ',' into table lt_tab.
 loop at lt_tab.
 endloop.
endloop.

Edited by: Jan Hoblik on Nov 16, 2010 10:24 AM