‎2006 Apr 15 12:22 PM
I need to know how can we export data from SAP data to a CSV Format file while downloading. It will be very helpful to me.
Thanks and regards.
Omer Farook.
‎2006 Apr 15 12:35 PM
Omer,
I am assuming that you are trying to download the data to your application server.
Assuming you have the internal table T_DATA.
DATA FNAME(60) VALUE 'myfile'.
DATA : record type string.
OPEN DATASET FNAME FOR OUTPUT.
LOOP AT T_data.
CONCATENATE COLUMN1, COLUMN2, ... INTO RECORD SEPARATED BY ','.
TRANSFER RECORD TO FNAME
clear record
endloop.
CLOSE DATASET FNAME.
Regards,
Ravi
Note : If this solves your issus, please close the thread by marking the stars on left side of the screen.
‎2006 Apr 15 12:35 PM
Omer,
I am assuming that you are trying to download the data to your application server.
Assuming you have the internal table T_DATA.
DATA FNAME(60) VALUE 'myfile'.
DATA : record type string.
OPEN DATASET FNAME FOR OUTPUT.
LOOP AT T_data.
CONCATENATE COLUMN1, COLUMN2, ... INTO RECORD SEPARATED BY ','.
TRANSFER RECORD TO FNAME
clear record
endloop.
CLOSE DATASET FNAME.
Regards,
Ravi
Note : If this solves your issus, please close the thread by marking the stars on left side of the screen.
‎2006 Apr 15 12:43 PM
Hi,
Check this sample code...
report ztest.
type-pools:TRUXS.
data: begin of itab occurs 0,
vbeln like vbap-vbeln,
posnr like vbap-posnr,
end of itab.
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 = 'C:TEMPtest.TXT'
TABLES
data_tab = itab1
EXCEPTIONS
OTHERS = 1.Regards
vijay
‎2006 Apr 15 2:11 PM
Hi Vijay. Thanks for your response. This function module is working with a semicolon and i need a comma to be inserted. if you have suggestions kindly help me.
regards
omer farook.
‎2006 Apr 15 2:33 PM
Hi Omer,
Inside the FM SAP_CONVERT_TO_CSV_FORMAT, field separator is hardcoded to semicolon. Irrespective of any value passed to FM, it will consider only semicolcon.
Thanks
Lakshman
‎2006 Apr 16 4:30 PM
Omer,
Simple solution for you would be to copy the FM SAP_CONVERT_TO_CSV_FORMAT into your own FM and pass COMMA instead of the hardcoded SEMICOLON to the FM.
Cheers
Nishanth