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 FILE Format Problem with ';'

Former Member
0 Likes
1,252

IS there a way to tell the function to use '<b>,</b>' instead of '<b>;</b>'?

I am using this

I_FIELD_SEPERATOR = ','

Still the output files shows-up with ';'

I need the output file as <b>.CSV</b>

any solutions please

...

CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'

EXPORTING

I_FIELD_SEPERATOR = ','

TABLES

I_TAB_SAP_DATA = OUTPUT_REC

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 = v_outputfile

TABLES

DATA_TAB = itab1

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_WRITE_ERROR = 2

INVALID_FILESIZE = 3

INVALID_TABLE_WIDTH = 4

INVALID_TYPE = 5

NO_BATCH = 6

UNKNOWN_ERROR = 7

OTHERS = 8.

...

Message was edited by: Anwarul Kabir

<b></b>

Message was edited by: Anwarul Kabir

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,191

Hi,

Try to use the FM SAP_CONVERT_TO_TEX_FORMAT. THis FM is called inside the function module SAP_CONVERT_TO_CSV_FORMAT..

Thanks,

Naren

11 REPLIES 11
Read only

Former Member
0 Likes
1,192

Hi,

Try to use the FM SAP_CONVERT_TO_TEX_FORMAT. THis FM is called inside the function module SAP_CONVERT_TO_CSV_FORMAT..

Thanks,

Naren

Read only

0 Likes
1,191

it works for .txt files but i need the output file to be .csv

Read only

0 Likes
1,191

Hi

A CSV file is a text file and that fm seems not to use the parameter filename, so it should work for csv file too.

Max

Read only

0 Likes
1,191

When I change the extension to csv it chages the account number to 1.45592E+11 from 145591769339. is there anyway to prevent it from doing so?

Read only

Former Member
0 Likes
1,191

Hi

Try to use directly SAP_CONVERT_TO_TEX_FORMAT

Max

Read only

Former Member
0 Likes
1,191

hi anwarul,

instead pf using function module

take one internal table say IT_UPLOAD' in that

REC(300) TYPE C,

and SPLIT IT_UPLOAD AT ','

INTO

yu internal table.

it will work.

Read only

Former Member
0 Likes
1,191

Hi,

Check this example..

TYPE-POOLS: TRUXS.

DATA: BEGIN OF T_INPUT OCCURS 0,

CHAR4(4) VALUE 'ABCD',

CHAR10(10) VALUE '1234567890',

CHAR20(20) VALUE '12345678901234567890',

END OF T_INPUT.

DATA: T_OUTPUT TYPE TRUXS_T_TEXT_DATA.

APPEND T_INPUT.

CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'

EXPORTING

i_field_seperator = ','

tables

i_tab_sap_data = T_INPUT

CHANGING

I_TAB_CONVERTED_DATA = T_OUTPUT

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 = 'C:\TEST_FILE.CSV'

tables

data_tab = T_OUTPUT

EXCEPTIONS

FILE_WRITE_ERROR = 1

NO_BATCH = 2

GUI_REFUSE_FILETRANSFER = 3

INVALID_TYPE = 4

NO_AUTHORITY = 5

UNKNOWN_ERROR = 6

HEADER_NOT_ALLOWED = 7

SEPARATOR_NOT_ALLOWED = 8

FILESIZE_NOT_ALLOWED = 9

HEADER_TOO_LONG = 10

DP_ERROR_CREATE = 11

DP_ERROR_SEND = 12

DP_ERROR_WRITE = 13

UNKNOWN_DP_ERROR = 14

ACCESS_DENIED = 15

DP_OUT_OF_MEMORY = 16

DISK_FULL = 17

DP_TIMEOUT = 18

FILE_NOT_FOUND = 19

DATAPROVIDER_EXCEPTION = 20

CONTROL_FLUSH_ERROR = 21

OTHERS = 22

.

IF sy-subrc <> 0.

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

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

ENDIF.

THanks,

Naren

Read only

0 Likes
1,191

I have the same code. the out put files shows with ';' not ','

Read only

Former Member
0 Likes
1,191

Hi,

Openwith a notepad instead of excel..

Thanks,

Naren

Read only

Former Member
0 Likes
1,191

Hi,

Did you check my sample code..It is working fine for me..

In the output file I am having the following data..

ABCD<b>,</b>1234567890<b>,</b>12345678901234567890

Thanks,

Naren

Read only

0 Likes
1,191

Thank you all. Naren your code was eaxctly as mine but i was onpenning it in xl which you pointed out. so its working thanks.