Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Read file by delimiter

Former Member
0 Kudos
308

I have a program which will read a text file and put the data into a internal table, the snipple code as the follows, but it only can extract the data and put it into internal table by tab delimiter. if the data is separator by comma, it can not read properly, How can i read the file by comma delimiter. Thanks!

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = wa_file

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

TABLES

DATA_TAB = temp_file_record

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

INVALID_TYPE = 5

NO_AUTHORITY = 6

UNKNOWN_ERROR = 7

BAD_DATA_FORMAT = 8

HEADER_NOT_ALLOWED = 9

SEPARATOR_NOT_ALLOWED = 10

HEADER_TOO_LONG = 11

UNKNOWN_DP_ERROR = 12

ACCESS_DENIED = 13

DP_OUT_OF_MEMORY = 14

DISK_FULL = 15

DP_TIMEOUT = 16

OTHERS = 17.

4 REPLIES 4

Former Member
0 Kudos
139

Hi,

Assign ',' for HAS_FIELD_SEPARATOR.

i.e.,

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = wa_file

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = ','

TABLES

DATA_TAB = temp_file_record

EXCEPTIONS

FILE_OPEN_ERROR = 1

Former Member
0 Kudos
139

Dont use the field seperator 'X', instead use field seperator ','. It will solve your problem.

HAS_FIELD_SEPARATOR = ','

Regards,

Maha

0 Kudos
139

I've already try to change HAS_FIELD_SEPARATOR = ',', but it cannot read each block into internal table, it will extract whole string append to first block of internal table. Is it abap bug? Thanks!

Former Member
0 Kudos
139

if it is appending the full rwo then..u can write a code where u can split each row of internal table at ',' and then store the values in the corresponding fields.