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

Problem with comma separated .CSV file.

Former Member
0 Likes
2,303

Hi,

I am facing a problem in creating comma separated .CSV file. Its downloading in the semi column (0040000001;000010) separated. In fact, I need it in comma separated (0040000001,000010).

Here is my code. Can you please suggest what changes needs to be done.

TYPES: CHAR4096(4096) TYPE C.

TYPES: BEGIN OF ITAB,

VBELN LIKE VBAP-VBELN,

POSNR LIKE VBAP-POSNR,

END OF ITAB.

DATA: IT_ITAB TYPE TABLE OF ITAB.

DATA: DO_ITAB TYPE TABLE OF CHAR4096,

LV_GUI_SEP TYPE C value ','.

SELECT VBELN

POSNR

UP TO 10 ROWS

FROM VBAP

INTO TABLE IT_ITAB.

CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'

EXPORTING

I_FIELD_SEPERATOR = LV_GUI_SEP

TABLES

I_TAB_SAP_DATA = IT_ITAB[]

CHANGING

I_TAB_CONVERTED_DATA = DO_ITAB[]

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:\abc.csv'

FILETYPE = 'ASC'

WRITE_FIELD_SEPARATOR = LV_GUI_SEP

TABLES

DATA_TAB = DO_ITAB

EXCEPTIONS

FILE_WRITE_ERROR = 1

NO_BATCH = 2

GUI_REFUSE_FILETRANSFER = 3

INVALID_TYPE

Thanks in advance for your help!

Regards,

Sri.

3 REPLIES 3
Read only

Former Member
0 Likes
1,295

srikanth,

the reason is very silly.. yes, you can say stupid here(not from your part from SAP part).. the FM 'SAP_CONVERT_TO_CSV_FORMAT' does not consider the separator provided by you.. it just hard codes ';'

so i change the FM to 'SAP_CONVERT_TO_TEX_FORMAT'.. and it works fine.

CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'"'SAP_CONVERT_TO_CSV_FORMAT'
EXPORTING
I_FIELD_SEPERATOR = LV_GUI_SEP
TABLES
I_TAB_SAP_DATA = IT_ITAB[]
CHANGING
I_TAB_CONVERTED_DATA = DO_ITAB[]
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2.

Read only

Former Member
0 Likes
1,295

Hi Soumyaprakash,

I have used the function module 'SAP_CONVERT_TO_TEX_FORMAT', Its converting with comma separated in intrenal table.

But when i download the interanal table in .CSV file, Fields are coming in different columns with out comma separated in one column. Do i need to check any settings??

Can you please check.

CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'

EXPORTING

I_FIELD_SEPERATOR = ','

TABLES

I_TAB_SAP_DATA = IT_ITAB[]

CHANGING

I_TAB_CONVERTED_DATA = DO_ITAB[].

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

FILENAME = 'C:\abc.csv'

FILETYPE = 'ASC'

WRITE_FIELD_SEPARATOR = LV_GUI_SEP

TABLES

DATA_TAB = DO_ITAB

EXCEPTIONS

FILE_WRITE_ERROR = 1

NO_BATCH = 2

GUI_REFUSE_FILETRANSFER = 3

INVALID_TYPE = 4.

Regards,

Sri.

Read only

0 Likes
1,295

srikanth.. that is CSV... open that downloaded content in notepad.. .you can see the commas...