06-15-2006 4:23 PM
Hi,
Is it possible to downlad internal table to external file of type CSV ??
(The FM GUI_DOWNLOAD doesn't enable that)..
Thanks,
06-15-2006 4:30 PM
You can use GUI_DOWNLOAD to do this, but you need to pass a flat table with the data separated by commas.
report zrich_0001 .
data: it001 type table of t001 with header line.
data: iout type table of string .
data: xout type string.
field-symbols: <fs>.
select * into table it001 from t001.
loop at it001.
clear xout.
do.
assign component sy-index of structure it001 to <fs>.
if sy-subrc <> 0.
exit.
endif.
if sy-index = 1.
xout = <fs>.
else.
concatenate xout <fs> into xout separated by ','.
endif.
enddo.
append xout to iout.
endloop.
call function 'GUI_DOWNLOAD'
exporting
filename = 'C:test.csv'
tables
data_tab = iout.
Regards,
Rich Heilman
06-15-2006 4:26 PM
The function GUI_DOWNLOAD has a field called SEPARATOR. Specify , there - then you should have a CSV file.
Regards,
Ravi
06-15-2006 4:27 PM
06-15-2006 4:30 PM
You can use GUI_DOWNLOAD to do this, but you need to pass a flat table with the data separated by commas.
report zrich_0001 .
data: it001 type table of t001 with header line.
data: iout type table of string .
data: xout type string.
field-symbols: <fs>.
select * into table it001 from t001.
loop at it001.
clear xout.
do.
assign component sy-index of structure it001 to <fs>.
if sy-subrc <> 0.
exit.
endif.
if sy-index = 1.
xout = <fs>.
else.
concatenate xout <fs> into xout separated by ','.
endif.
enddo.
append xout to iout.
endloop.
call function 'GUI_DOWNLOAD'
exporting
filename = 'C:test.csv'
tables
data_tab = iout.
Regards,
Rich Heilman
06-15-2006 4:33 PM
Hi,
Check the code...
REPORT ZTESTAA.
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
06-15-2006 4:34 PM
hi
you can specify the format of file as CSV in the SEPARATOR parameter of GUI_DOWNLOAD or you can use the FM .SAP_CONVERT_TO_CSV_FORMAT'.
Regards,
Richa
06-15-2006 4:35 PM
Hi,
It is possible with GUI_DOWNLOAD.
Check this Code
CONSTANTS :
lc_file_type TYPE char10 VALUE 'DAT'.
DATA : lit_head_det TYPE TABLE OF ty_head_det,
wa_head_det LIKE LINE OF lit_head_det,
lit_head_sum TYPE TABLE OF ty_head_sum,
wa_head_sum LIKE LINE OF lit_head_sum,
lv_file_name TYPE string.
CLEAR: lit_head_det[],
wa_head_det,
lv_file_name.
*----------------Column Header for Detail Report----------------------*
* wa_head_det-create_date = text-023 .
wa_head_det-partner = text-046 .
* wa_head_det-bpext = text-047 .
wa_head_det-leg_sp_id = text-047 .
wa_head_det-nomship_ref = text-024 .
wa_head_det-offer = text-025 .
wa_head_det-conf_ref_no = text-026 .
wa_head_det-con_eff_date = text-027 .
wa_head_det-activity_date = text-028 .
wa_head_det-rej_text = text-029 .
wa_head_det-trf_date = text-030 .
wa_head_det-mprn = text-031 .
wa_head_det-mprn_status = text-032 .
wa_head_det-mam_app = text-036 .
wa_head_det-open_read = text-010 .
APPEND wa_head_det TO lit_head_det.
*----------------Column Header for Summary Report----------------------*
wa_head_sum-date = text-023 .
wa_head_sum-count = text-051 .
APPEND wa_head_sum TO lit_head_sum.
*----------------Progress Indicator For the User----------------------*
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
percentage = 100
text = text-053
EXCEPTIONS
OTHERS = 1.
* SY-SUBRC Check Not Required
*----------------Download Detail Report to Excel----------------------*
*---Assign Detail File Path
lv_file_name = xv_det_fp.
*---Load Header Data of Detail Report
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = lv_file_name
filetype = lc_file_type
write_field_separator = lc_true
codepage = '4103'
TABLES
data_tab = lit_head_det
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.
*----Load Detail Report Data to Excel File
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = lv_file_name
filetype = lc_file_type
append = lc_true
write_field_separator = lc_true
codepage = '4103'
TABLES
data_tab = lit_det_report
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.
ENDIF.
IF sy-subrc <> 0.
* 202 : Error Occurred while writing data to the file.
MESSAGE e202(zusm_gen) .
EXIT.
ELSE.
WRITE 😕 text-042 , lv_file_name.
ENDIF.
06-15-2006 4:40 PM
Hi,
Yes it is possible to do.
For downloading file on application server :
Open dataset ...
loop at itab into wa_tab.
concatenate wa_tab-field1
wa_tab-field2
separated by ','
into l_record.
endloop.
transfer l_record into l_file.
close dataset.
For downloading on presentation server,
Pass separator in the parameter.
Best regards,
Prashant
06-15-2006 5:15 PM
Thank you all.
It is pity that possible to assign 10 points for one post only