Application Development and Automation 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 only

Excel upload - remove line break

Former Member
0 Likes
1,061

Hi experts,

I want to read an excel sheet using function module GUI_UPLOAD. Everything is working well, except for cells with line break. How can I remove line break in my code? The excel has CSV format.

My code looks as follows:

..

..

..

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = file_str

TABLES

data_tab = itab

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.

LOOP AT itab.

CLEAR idat.

SPLIT itab-rec AT ',' INTO idat-fld1

idat-fld2

idat-fld3.

APPEND idat.

ENDLOOP.

LOOP AT idat.

WRITE:/ idat-fld1, idat-fld2, idat-fld3.

ENDLOOP.

As you can see I use the seperator ';'. The problem is that cells with line break dislocate my data, although I use ';' as seperator the cells get seperated when there is a line break too (and they get seperated by ';'.If there is no line break, everything working well).

What do I have to do to declare line breake as line breake, if I want to use the function 'REPLACE ALL OCCURRENCES OF ' ' IN itab-rec WITH ' '? I would replace the line breake with an blank or something like that.

Please don´t offer a complete new solution, because this one is working very fine and I´m just searching for a solution to solve problem with line break.

Thanks a lot.

Regards

Anna

Hi experts,

I want to read an excel sheet using function module GUI_UPLOAD. Everything is working well, except for cells with line break. How can I remove line break in my code? The excel has CSV format.

My code looks as follows:

..

..

..

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = file_str

TABLES

data_tab = itab

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.

LOOP AT itab.

CLEAR idat.

SPLIT itab-rec AT ',' INTO idat-fld1

idat-fld2

idat-fld3.

APPEND idat.

ENDLOOP.

LOOP AT idat.

WRITE:/ idat-fld1, idat-fld2, idat-fld3.

ENDLOOP.

As you can see I use the seperator ';'. The problem is that cells with line break dislocate my data, although I use ';' as seperator the cells get seperated when there is a line break too (and they get seperated by ';'.If there is no line break, everything working well).

What do I have to do to declare line breake as line breake, if I want to use the function 'REPLACE ALL OCCURRENCES OF ' ' IN itab-rec WITH ' '? I would replace the line breake with an blank or something like that.

Please don´t offer a complete new solution, because this one is working very fine and I´m just searching for a solution to solve problem with line break.

Thanks a lot.

Regards

Anna

2 REPLIES 2
Read only

former_member156446
Active Contributor
0 Likes
692
LOOP AT itab into wa_itab.
REPLACE ALL OCCURRENCES OF CL_ABAP_CHAR_UTILITIES=>CR_LF in wa_itab-<field> with space.
CLEAR idat.
SPLIT itab-rec AT ',' INTO idat-fld1
idat-fld2
idat-fld3.
APPEND idat.

ENDLOOP.
Read only

0 Likes
692

Hi,

thank you for quick reply.

What is wa_itab-CR_LF IN itab-rec with space.

CLEAR idat.

SPLIT itab-rec AT ',' INTO...

ENDLOOP.

..

..

I wrote this code and it doesn´t work. The program still sets the line break.

Thank you very much.

Anna