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

Writing data to in .CSV format

Former Member
0 Likes
2,321

hi,

i've a problem while writing the data from an internal table which consist of some 5 data to a flat file of .CSV format . All the values that are written to the flat file are displayed in the first row first column ony. Is there any method to display the values in different lines ? .

with regards.

T.Jeyagopi

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,566

hi ,

u need tab delimit and a line break at the end of each record for that u declare a variable of hexdecimal type with value '09' for tab delimit and '0D' for line break .concatenate hex- 09 between the fields and hex '0d' at end of record this may solve ur problem . remember this concatnation work only in non-unicode system . if ur working in unicode system u can use this class attr. cl_abap_char_utilities=>horizontal_tab and cl_abap_char_utilities=>cr_lf assign it to char type field itself and concatenate as said .hope this may solve ur problem .

hi,

i've a problem while writing the data from an internal table which consist of some 5 data to a flat file of .CSV format . All the values that are written to the flat file are displayed in the first row first column ony. Is there any method to display the values in different lines ? .

with regards.

T.Jeyagopi

5 REPLIES 5
Read only

athavanraja
Active Contributor
0 Likes
1,566

you have concatenate all the fileds separated by a comma (,) and at the end of each record CL_ABAP_CHAR_UTILITIES=>cr_lf.

also make sure that none of your field values have comma .

Regards

Raja

Read only

Former Member
0 Likes
1,566

Hi,

I suppose, that you are using FM 'WS_DOWNLOAD' or 'GUI_DOWNLOAD'. If you use FILETYPE = 'ASC', then all fields will be in one column. In such a case you should create a new internal table with one field, combined of all fields separated by ';'. If you use FILETYPE = 'DAT', your fields will be tab separated directly.

If you find the answer helpful, please assign reward points.

Svetlin

Message was edited by: Svetlin Rusev

Read only

andreas_mann3
Active Contributor
0 Likes
1,566

Hi ,

try this:

data delimiter value ';'.
loop at itab.
...
clear string.
do.
assign component sy-index of structure itab to <f>.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
concatenate string <f> delimiter into string.
enddo.

append string to tab_download.

...
endloop.
...

CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILETYPE = 'ASC'
FILENAME = FILE
TABLES
DATA_TAB = tab_download.

Andreas

Read only

Former Member
0 Likes
1,567

hi ,

u need tab delimit and a line break at the end of each record for that u declare a variable of hexdecimal type with value '09' for tab delimit and '0D' for line break .concatenate hex- 09 between the fields and hex '0d' at end of record this may solve ur problem . remember this concatnation work only in non-unicode system . if ur working in unicode system u can use this class attr. cl_abap_char_utilities=>horizontal_tab and cl_abap_char_utilities=>cr_lf assign it to char type field itself and concatenate as said .hope this may solve ur problem .

Read only

suresh_datti
Active Contributor
0 Likes
1,566

Hi,

You can also use the delivered function module 'SAP_CONVERT_TO_CSV_FORMAT' to convert the data inside the program; and then download to the frontend or transfer to the application server as the case may be..

Good Luck,

Suresh Datti