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

csv format

Former Member
0 Likes
823

hi all,

can neone help on issue to how to download the contents of the internal table in csv format seperated ny , . i have tried using gui_download but its comming in csv but all the column is comming into a single column.

8 REPLIES 8
Read only

Former Member
0 Likes
790

Try the FM

KCD_CSV_FILE_TO_INTERN_CONVERT

Reward Points if useful.

Read only

Former Member
0 Likes
790

Hi,

Use GUI_DOWNLOAD.

Set write_field_separator as ',' (comma).

Its works fine.

Ex:

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = l_f_filename

write_field_separator = ','

TABLES

data_tab = g_t_header

EXCEPTIONS

file_write_error = 1

Read only

Former Member
0 Likes
790

Hi,

In the GUI_DOWNLOAD function change field

seprator = 'X'.

It will work.

Thanks

Umesh

Read only

Former Member
0 Likes
790

Hi,

USe the fallowing code:

data: ts_csv type TRUXS_T_TEXT_DATA.

CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'

EXPORTING

I_FIELD_SEPERATOR = ','

  • I_LINE_HEADER =

  • I_FILENAME =

  • I_APPL_KEEP = ' '

TABLES

I_TAB_SAP_DATA = ts_extract

CHANGING

I_TAB_CONVERTED_DATA = ts_csv

EXCEPTIONS

CONVERSION_FAILED = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

FILENAME = v_fname

  • FILETYPE = 'ASC'

  • APPEND = ' '

  • WRITE_FIELD_SEPARATOR = ' '

  • HEADER = '00'

  • TRUNC_TRAILING_BLANKS = ' '

  • WRITE_LF = 'X'

  • COL_SELECT = ' '

  • COL_SELECT_MASK = ' '

  • DAT_MODE = ' '

  • CONFIRM_OVERWRITE = ' '

  • NO_AUTH_CHECK = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • WRITE_BOM = ' '

  • TRUNC_TRAILING_BLANKS_EOL = 'X'

  • WK1_N_FORMAT = ' '

  • WK1_N_SIZE = ' '

  • WK1_T_FORMAT = ' '

  • WK1_T_SIZE = ' '

  • WRITE_LF_AFTER_LAST_LINE = ABAP_TRUE

  • IMPORTING

  • FILELENGTH =

TABLES

DATA_TAB = ts_csv

  • FIELDNAMES =

EXCEPTIONS

PS: Reward Points for successfull results.

Regards

Naveen Gupta

Read only

Former Member
0 Likes
790

hi abinash,

the following is a sample, i hope this will be useful to you

REPORT ZSAMPLEFORDOWNLOADDATATOCSV.

TYPE-POOLS: truxs.

TYPES:

BEGIN OF ty_Lines,

vbeln LIKE vbap-vbeln,

posnr LIKE vbap-posnr,

END OF ty_Lines.

data: ty_Lines TYPE STANDARD TABLE of ty_lines WITH DEFAULT KEY.

DATA: itab TYPE ty_Lines occurs 0.

DATA: itab1 TYPE truxs_t_text_data.

SELECT

vbeln

posnr

UP TO 10 ROWS

FROM vbap

INTO TABLE itab.

CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'

EXPORTING

i_field_seperator = ';'

TABLES

i_tab_sap_data = itab

CHANGING

i_tab_converted_data = itab1

EXCEPTIONS

conversion_failed = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = 'd:\TEMP\test.txt'

TABLES

data_tab = itab1

EXCEPTIONS

OTHERS = 1.

Reward Points if useful

regards,

pavan

Edited by: pavan kumar pisipati on Dec 18, 2007 10:11 AM

Read only

Former Member
0 Likes
790

if u already hav data in internal table with commas in table..

Use REPLACE ALL OCCURENCES OF ',' WITH ''.

Hope dis helps..

Reward all helpful ans

Read only

0 Likes
790

Hi,

Please tell me the ful code, i have some simmilar kind of requirement.

Read only

Former Member
0 Likes
790

answered