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

FM SAP_CONVERT_TO_CSV_FORMAT - separator is wrong.

Former Member
0 Likes
4,722

I am using FM SAP_CONVERT_TO_CSV_FORMAT and I have the field separator as a comma but when the file is exported it has the separator as a semicolon. Does anybody have any ideas why this is happening? Below is my code and a portion of the exported document:

CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
    EXPORTING
      i_field_seperator    = ','
    TABLES
      i_tab_sap_data       = it_table
    CHANGING
      i_tab_converted_data = it_table_csv
    EXCEPTIONS
      conversion_failed    = 1
      OTHERS               = 2.

  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      filename = w_filename
    TABLES
      data_tab = it_table_csv
    EXCEPTIONS
      OTHERS   = 1.

0080629699;04/05/2007;LF;04/05/2007;0520;H1;01;PP;Destination;0000200471;DI;0000200471

Regards,

Davis

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,547

Hi,

Please try FM SAP_CONVERT_TO_TEX_FORMAT instead.

Regards,

Ferry Lianto

I am using FM SAP_CONVERT_TO_CSV_FORMAT and I have the field separator as a comma but when the file is exported it has the separator as a semicolon. Does anybody have any ideas why this is happening? Below is my code and a portion of the exported document:

CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
    EXPORTING
      i_field_seperator    = ','
    TABLES
      i_tab_sap_data       = it_table
    CHANGING
      i_tab_converted_data = it_table_csv
    EXCEPTIONS
      conversion_failed    = 1
      OTHERS               = 2.

  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      filename = w_filename
    TABLES
      data_tab = it_table_csv
    EXCEPTIONS
      OTHERS   = 1.

0080629699;04/05/2007;LF;04/05/2007;0520;H1;01;PP;Destination;0000200471;DI;0000200471

Regards,

Davis

8 REPLIES 8
Read only

Former Member
0 Likes
2,547

I just tried it again but using '|' as the separator and it still comes through as a semicolon. Is it not possible to override the default?

Davis

Read only

Former Member
0 Likes
2,548

Hi,

Please try FM SAP_CONVERT_TO_TEX_FORMAT instead.

Regards,

Ferry Lianto

Read only

0 Likes
2,547

Ferry,

That worked like a charm. While you did answer my question I have another question relating to this FM. Is there any way to add the column titles to the csv table?

Davis

Read only

0 Likes
2,547

Davis,

CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'

EXPORTING

I_FIELD_SEPERATOR = C_FIELD_SEPARATOR

<b> I_LINE_HEADER = I_LINE_HEADER</b> I_FILENAME = I_FILENAME

TABLES

I_TAB_SAP_DATA = I_TAB_SAP_DATA

CHANGING

I_TAB_CONVERTED_DATA = I_TAB_CONVERTED_DATA

EXCEPTIONS

CONVERSION_FAILED = C_RC4.

See the bold one ,you can add column titles here.

Thanks

Seshu

Read only

0 Likes
2,547

Thanks Seshu. I did not try that parameter because it looked to me like it would only accept a field of type Char01. I will try that out.

Thanks,

Davis

Read only

Former Member
0 Likes
2,547

It looks like the function module calls another function module (see below) in which it passes the constant field separator which is defined as a semi colon.

CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'

EXPORTING

I_FIELD_SEPERATOR = C_FIELD_SEPARATOR

I_LINE_HEADER = I_LINE_HEADER

I_FILENAME = I_FILENAME

TABLES

I_TAB_SAP_DATA = I_TAB_SAP_DATA

CHANGING

I_TAB_CONVERTED_DATA = I_TAB_CONVERTED_DATA

EXCEPTIONS

CONVERSION_FAILED = C_RC4.

Read only

0 Likes
2,547

Fred, I was just about to post that. It doesn't make much sense that SAP would tell you that you can change it when you really can't. This makes me want to find the developer and give him a swift kick in the butt.

Ferry, I will try your solution, thanks.

Davis

Read only

0 Likes
2,547

You can use GUI_DOWNLOAD FM ,for field separator :

*"----


""Lokale Schnittstelle:

*" IMPORTING

*" REFERENCE(BIN_FILESIZE) TYPE I OPTIONAL

*" REFERENCE(FILENAME) TYPE STRING

*" REFERENCE(FILETYPE) TYPE CHAR10 DEFAULT 'ASC'

*" REFERENCE(APPEND) TYPE CHAR01 DEFAULT SPACE

*" <b>REFERENCE(WRITE_FIELD_SEPARATOR) TYPE CHAR01</b> DEFAULT SPACE

*" REFERENCE(HEADER) TYPE XSTRING DEFAULT '00'

*" REFERENCE(TRUNC_TRAILING_BLANKS) TYPE CHAR01 DEFAULT SPACE

*" REFERENCE(WRITE_LF) TYPE CHAR01 DEFAULT 'X'

*" REFERENCE(COL_SELECT) TYPE CHAR01 DEFAULT SPACE

*" REFERENCE(COL_SELECT_MASK) TYPE CHAR255 DEFAULT SPACE

*" REFERENCE(DAT_MODE) TYPE CHAR01 DEFAULT SPACE

*" EXPORTING

*" VALUE(FILELENGTH) TYPE I

*" TABLES

*" DATA_TAB

*" EXCEPTIONS

*" FILE_WRITE_ERROR

*" NO_BATCH

*" GUI_REFUSE_FILETRANSFER

*" INVALID_TYPE

*" NO_AUTHORITY

*" UNKNOWN_ERROR

*" HEADER_NOT_ALLOWED

*" SEPARATOR_NOT_ALLOWED

*" FILESIZE_NOT_ALLOWED

*" HEADER_TOO_LONG

*" DP_ERROR_CREATE

*" DP_ERROR_SEND

*" DP_ERROR_WRITE

*" UNKNOWN_DP_ERROR

*" ACCESS_DENIED

*" DP_OUT_OF_MEMORY

*" DISK_FULL

*" DP_TIMEOUT

*" FILE_NOT_FOUND

*" DATAPROVIDER_EXCEPTION

*" CONTROL_FLUSH_ERROR

Thanks

Seshu