cancel
Showing results for 
Search instead for 
Did you mean: 

Error in uploading content of file int internal table

Former Member
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

athavanraja
Active Contributor
0 Kudos

if the file is a tab delimited one then for splitting use

split xx at CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB

Former Member
0 Kudos

No boss its not working....

Its not spliting... its showing in debugging mode as ##...

Example

if my text fie is as

11

22

33

44

Its uploaded convertedinto string as 11##22##33##44####

this is waht i am able to see in debugging mode/

athavanraja
Active Contributor
0 Kudos

each number in a different row? then i guess its a line feed . in this case use

CL_ABAP_CHAR_UTILITIES=>CR_LF

Former Member
0 Kudos

Thanks boss.. I have done it ...

Ya u were write it was line feed

Thanks a lot..

Answers (0)