cancel
Showing results for 
Search instead for 
Did you mean: 

<htmlb:fileUpload>

shiva_suvarna
Participant
0 Kudos

Hi friends,

I watched the no of posts that were on the same following topic, but none of them were answered perfectly, that's why i am posting it, please don't mind.

I want to upload the excel file through <htmlb:fileUpload> and read the data of excel sheet into an internal table , i think we can achieve this for TAB delimited excel files,

but in our case we want to accept normal excel files also, so any body if you solution suggest me.

Accepted Solutions (1)

Accepted Solutions (1)

athavanraja
Active Contributor
0 Kudos

you can only do it with CSV or TAB delimited excel files.

Shailaja had given you the solution for tab delimited files and the same can be modified slightly to work for CSV files as well.

Regards

Raja

Close your previous threads

Message was edited by: Durairaj Athavan Raja

shiva_suvarna
Participant
0 Kudos

hi shailaja and raja,

Yes i tried with TAB delimited and CSV excel files , they worked fine,

ok here in our case we have to accept normal files also , if you know the solution please share with me.

Raja, ok i will close that thread why i haven't closed because, i read that weblog you specified ,it is fine if we know the parameters and it's values , For onRowSelect event i have to know the parameter values like (2:150001966A,1,5,3,P ),row no, key etc and i have to parameters in correct sequence while rendering.

this is some what complex , i am waiting for simple solution, that's why i haven't closed the thread.

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Shiva,

Go through the sample code to be written in the onInputProcessing,

data: entity type ref to if_http_entity,

file type xstring,

content_type type string,

content_length type string,

num_multiparts type i,

i type i value 1,

doEcho type string,

value type string.

  • find multipart containing file

num_multiparts = request->num_multiparts( ).

while i <= num_multiparts.

entity = request->get_multipart( i ).

value = entity->get_header_field( '~content_filename' ).

if not value is initial.

  • found a file!

navigation->set_parameter( name = 'content_filename'

value = value ).

content_type = entity->get_header_field( 'Content-Type' ).

navigation->set_parameter( name = 'content_type'

value = content_type ).

  • get file content

file = entity->get_data( ).

  • get file size

content_length = xstrlen( file ).

navigation->set_parameter( name = 'content_length'

value = content_length ).

  • echo/download the same file again?

doEcho = request->get_form_field( 'doEcho' ).

if doEcho is not initial.

  • set response data to be the file content

runtime->server->response->set_data( file ).

  • set the mime-type and file size in the response

runtime->server->response->set_header_field(

name = 'Content-Type'

value = content_type ).

runtime->server->response->set_header_field(

name = 'Content-Length'

value = content_length ).

runtime->server->response->delete_header_field(

name = 'Cache-Control' ).

runtime->server->response->delete_header_field(

name = 'Expires' ).

endif.

exit.

endif.

i = i + 1.

endwhile.

if doEcho is not initial.

  • signal to the BSP runtime that the response data is

  • complete and no onLayout method should be called to

  • create the response

navigation->response_complete( ).

else.

navigation->goto_page( 'transition_parameter_upload.htm' ).

endif.

Regards,

Azaz Ali.

shiva_suvarna
Participant
0 Kudos

Hi ali and every body,

I want to read the excel data rows and columns as it is in internal table . here i am able to get the data in xstring later i can convert into string ,but that string is in encoded form . I want to decode it and store in internal table in rows and columns as they were specified in excel sheet.

Former Member
0 Kudos

Hi,

Did u try to upload an excel sheet saving as tab delimiter file? try that and try to upload. And in OnInputProcessing try like this:

data: conv TYPE REF TO CL_ABAP_CONV_IN_CE.

conv = cl_abap_conv_in_ce=>create( input = f_content ). "content of the file

conv->read( IMPORTING data = content len = len ). "length of the file

split content at cl_abap_char_utilities=>cr_lf into table text_tab1 . " your output table

loop at text_tab1 into wa_text .

split wa_text at cl_abap_char_utilities=>HORIZONTAL_TAB into wa_excel-colum1 wa_excel-column2 ........

append wa_excel to excel_itab

endloop.

Let me know if you need more info..

regards,

Shailaja

Former Member
0 Kudos