cancel
Showing results for 
Search instead for 
Did you mean: 

I'd like to divide line by line when insert file to internal table

Former Member
0 Kudos

I'd like to insert file to internal table.

when i add the file to itab i've got a problem.

I couldn't divide line by line.

this is my source. please help me!!

-


DATA: fileUpload TYPE REF TO CL_HTMLB_FILEUPLOAD.

DATA: file_content type xstring.

DATA: content type string.

DATA: tf type string.

DATA: CONV TYPE REF TO CL_ABAP_CONV_IN_CE.

DATA: LEN TYPE I.

fileUpload ?= CL_HTMLB_MANAGER=>GET_DATA(

request = request

id = 'myUpload'

name = 'fileUpload' ).

file_name = fileUpload->file_name.

file_mime_type = fileUpload->file_content_type.

file_length = fileUpload->file_length.

file_content = fileUpload->file_content.

conv = CL_ABAP_CONV_IN_CE=>CREATE( input = file_content ).

conv->READ( importing data = content len = len ).

open dataset content in text mode for input encoding default.

transfer content to tf.

append tf to itab.

close dataset content.

-


Accepted Solutions (1)

Accepted Solutions (1)

athavanraja
Active Contributor
0 Kudos

Welcome to SDN & wish you a happy new year.

<i>couldn't divide line by line.</i>

how do you want to divide? divide the lines where there is a line break or some specified length?

<u><b>A) specified length.</b></u>

use FM to split every 255 chars into a line

CALL FUNCTION 'CONVERT_STRING_TO_TABLE'

EXPORTING

i_string = content

i_tabline_length = "255"

TABLES

et_table = et_table

<u><b>B) to split where there is a carriage return</b></u>

data: itab TYPE TABLE OF string .

SPLIT content AT CL_ABAP_CHAR_UTILITIES=>CR_LF INTO TABLE itab.

Hope this helps.

Regards

Raja

Former Member
0 Kudos

thanks for your help.

I solved the problem.

athavanraja
Active Contributor
0 Kudos

is there any reason for unassigning the points?

Regards

Raja

Former Member
0 Kudos

sorry i'm late post message.

i solved my problem.

thank you for your help.

Answers (0)