Skip to Content
0
Former Member
Jan 07, 2008 at 03:57 AM

Error in uploading content of file int internal table

30 Views

I want to upload one file.Store the content into internall table. i ahve written the the following code under input processing.

  • event handler for checking and processing user input and

  • for defining navigation

  • file upload and echo

data: entity type ref to if_http_entity,

file type xstring,

content_type type string,

LV_DELIMITER type string VALUE '##',

content_length type string,

num_multiparts type i,

i type i value 1,

doEcho type string value 'xyz',

value type string,

conv TYPE REF TO CL_ABAP_CONV_IN_CE,

LV_DELIMITER1 type string VALUE ',',

content1 type string value '22##11##35',

content TYPE STRING.

DATA: BEGIN OF t_temp,

str(10) TYPE c,

END OF t_temp.

data : ty_temp type standard table of t_temp,

wa_temp like line of ty_temp.

  • 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( ).__

__conv = CL_ABAP_CONV_IN_CE=>CREATE( input = file ).__

__conv->READ( importing data = content ).__

__replace LV_DELIMITER with LV_DELIMITER1 into content1.__

__SPLIT content AT LV_DELIMITER1 INTO TABLE Ty_temp.__

  • 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.

I AM FACING SOME ISSUES IN THE in the highlited portion. whan i am spliting the sting into sub string...it is not giving desired result. In Debuging mode it is showing ## at the delimeter but it is not spliting.