‎2011 Jun 23 5:55 AM
Dear Experts,
I am using FM 'MS_EXCEL_OLE_STANDARD_DAT' to get data from internal table data to Excel, but all the records of internal table will print in one line of Excel sheet. Please share your idea's on how to fix this to get in excel as many records as of internal table.
Thanks in advance
Venkat
‎2011 Jun 23 6:16 AM
hello,
my solution for your issue is ALV grid. SAP provides standard functionality you can export ALV grid into excel pattern. first of all you have to select data from your DB table(-s) and place the result into internal table afterwards you have to output it into ALV grid then user can maintain the result which he got (delete, insert new rows change amount, text fields, sum columns, maintain layout and so on) or you could export ALV grid into ms:excel without possibility to see and maintain ALV grid via custom default layout variant (you have to set specific excel pattern as default. there is a tab strip for this propose). when you ve done all the correction you can export the result into excel by pressing button views->Excel inplace and vice versa -> choose your excel pattern or it will be done by the default variant. ALV grid exports tables header and item lines into excel (you can create additional work sheet with macros to retrieve, maintain and output final result). you have to import excel pattern executing BCALV_BDS_MAINTENANCE report via se38 transaction: check import templates radiobutton and create transport and execute again. now you will see the list of templates. from this spot you can add new tamples or remove them. remember - Excel patterns has a strict structure you can find examples via oaer transaction class name ALVLAYOUTTEMPLATES class type OT and execute (this tcode is used for patterns maintenance). open sap_standard_template folder double click on the pattern and now you will see whole structure. thats all. it is very easy. it's very fast way to transfer data from ECC to ms:excel.
it is very efficient is we are talking about data transfer speed.
best regards,
dez_
‎2011 Jun 23 6:18 AM
‎2011 Jun 23 6:24 AM
Hi,
Better use gui_download function module to download the internal table to excel sheet.
refer the link for example program for gui_donload.
http://www.freesaptutorial.com/how-to-download-internal-table-to-excel-using-abap-gui_download/
Regards,
Dhina..
‎2011 Jun 23 7:05 AM
Hi,
Either you can try with GUI_DOWNLOAD or else try the below logic.
Move all the data in the structure to a string seperated by cl_abap_char_utilities=>horizontal_tab. Pass this table of strings to 'MS_EXCEL_OLE_STANDARD_DAT'. See below for example.
Loop at itab.
concatenate itab-field1 itab-field-2 into wa_string separated by cl_abap_char_utilities=>horizontal_tab.
append wa_string to ta_string.
endloop.
CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'
EXPORTING
file_name = '\\excel.xls' "Path and name
TABLES
data_tab = ta_string.