2007 Dec 27 1:31 AM
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.
2007 Dec 27 1:52 AM
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
2007 Dec 27 2:11 AM
Dont use the field seperator 'X', instead use field seperator ','. It will solve your problem.
HAS_FIELD_SEPARATOR = ','
Regards,
Maha
2007 Dec 27 2:56 AM
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!
2007 Dec 28 5:25 AM
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.