Downloading internal table.
hi all,
i need to down load an internal table to text file.
i used fm upload ok its working fine.
my text file is like this
(line)
abc company
(line)
the following are the details
here internal table data will come.
i can display the internal table output in file,but i need code how to display that
line,abc company ,the following are the details in text file.
can any body provide some sample code for this.
thanks in advance
siva
thanks for ur response.
i will down load the data to text file from internal table using function module gui down load
in text file on the top of it i need text like this
abc company
itab-f1 itab-f2 itab-f3 itab-f4 itab-f5
i want the text abc company on the top of my text file ,i can down load itab-f1,f2,f3 into text file,i am able to do that.how can i down load the text abc company to text file.
thanks in advance
siva
Similar Messages
-
How to download internal table data to .xlsx file ?
Hello All,
I am using SAP ECC 6.0. I need to download internal table data to .xlsx file.
I tried GUI_DOWNLOAD, all the data are getting transferred to the .xlsx file, but while opening I am getting the below error.
Excel cannot open the file "download.xlsx" because file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file.
Though Microsoft office 2007 is installed in my system.
Please help <removed by moderator>.
Edited by: Thomas Zloch on Oct 24, 2011 10:55 AMHi,
Please find the below code to download data into excel file.
DATA: ld_filename TYPE string,
ld_path TYPE string,
ld_fullpath TYPE string,
ld_result TYPE i.
Display save dialog window
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
window_title = ' '
DEFAULT_EXTENSION = 'XLS'
default_file_name = 'accountsdata'
INITIAL_DIRECTORY = 'c:\temp\'
CHANGING
filename = ld_filename
path = ld_path
fullpath = ld_fullpath
user_action = ld_result.
Check user did not cancel request
CHECK ld_result EQ '0'.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = ld_fullpath
filetype = 'ASC'
APPEND = 'X'
write_field_separator = 'X'
CONFIRM_OVERWRITE = 'X'
TABLES
data_tab = it_datatab[] "need to declare and populate
EXCEPTIONS
file_open_error = 1
file_write_error = 2
OTHERS = 3.
Thanks and Regards
Chitra -
Download internal table to excel with header
Hi All,
I have a requirement to download internal table contents to excel with field headings. I tried searching in forums before posting but didn't got much help.
I have used GUI_DOWNLOAD, WS_DOWNLOAD and EXCEL_OLE_STANDARD_DAT.
But unable to download the header in excel..along with data...
EXCEL_OLE_STANDARD_DAT is getting field header in excel but not downloading automatically , need to save manually which is not the requirement.
The data is huge with around 151 columns....I got 2 internal tables.
One for the data and the other with field names.
Many Thanks,
Ravi KHi Ravi,
You need to have 2 different internal tables for achieving the needful. One internal table would be having your data and another would store your table field names i.e., declare a structure of length 100 characters,
TYPES : BEGIN OF GTY_FIELDNAMES,
TITLE(100),
END OF GTY_FIELDNAMES.
DATA: GIT_FIELDNAMES TYPE STANDARD TABLE OF GTY_FIELDNAMES,
GWA_FIELDNAMES TYPE GTY_FIELDNAMES.
DATA : GD_FILENAME TYPE STRING,
GD_PATH TYPE STRING,
GD_FULLPATH TYPE STRING,
GD_RESULT TYPE I.
Now have a subroutine where by you append your headings into the internal table i.e.,GIT_FIELDNAMES
CLEAR GWA_FIELDNAMES.
GWA_FIELDNAMES-TITLE = 'Material Number'.
APPEND GWA_FIELDNAMES TO GIT_FIELDNAMES.
CLEAR GWA_FIELDNAMES.
GWA_FIELDNAMES-TITLE = 'Material Description'.
APPEND GWA_FIELDNAMES TO GIT_FIELDNAMES.
Once you are done with it you can call up the save dialog
* Display save dialog window
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
EXPORTING
WINDOW_TITLE = 'Save File As...'
DEFAULT_EXTENSION = 'XLS'
DEFAULT_FILE_NAME = 'SalesPlan'
INITIAL_DIRECTORY = 'C:\'
CHANGING
FILENAME = GD_FILENAME
PATH = GD_PATH
FULLPATH = GD_FULLPATH
USER_ACTION = GD_RESULT.
* Check user did not cancel request
CHECK GD_RESULT EQ '0'.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = GD_FULLPATH
FILETYPE = 'ASC'
* APPEND = 'X'
WRITE_FIELD_SEPARATOR = 'X'
* CONFIRM_OVERWRITE = 'X'
TABLES
DATA_TAB = GIT_FINAL " Internal table having data
FIELDNAMES = GIT_FIELDNAMES " Internal table having headings
EXCEPTIONS
FILE_OPEN_ERROR = 1 "#EC ARGCHECKED
FILE_WRITE_ERROR = 2
OTHERS = 3.
Hope this gets sorted your problem.
Thanks & Regards,
Varun Kumar Sahu -
Download internal table data to Excel in background
Hi all ,
Can anyone tell that how i can download internal table data
into Excel sheet in Backgroud Mode .
I used both fun mod ws and gui download but these are not working in background mod .
Please help issue is urgent .
Answer is rewarded by point .
With Regards ,
Nilesh Jainhi,
you have to use function module 'SAP_CONVERT_TO_XLS_FORMAT'.
DATA:
ITAB1 TYPE TRUXS_T_TEXT_DATA.
CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
EXPORTING
I_FIELD_SEPERATOR = ';'
I_LINE_HEADER =
i_filename = filename
I_APPL_KEEP = ' '
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.
try this one.
reward points if useful,
thanks & regards,
rajee. -
How to download internal table data into xml file?
Hi,
Experts,
I have downloaded internal table data into XLS format using GUI_DOWNLOAD Function module, But i didn't Know how to download internal table data into XML format please post some ideas/inputs on this issue.
Thank you,
Shabeer ahmed.check this
data : gd_repid type sy-repid.
GD_REPID = SY-REPID.
DATA : L_DOM TYPE REF TO IF_IXML_ELEMENT,
M_DOCUMENT TYPE REF TO IF_IXML_DOCUMENT,
G_IXML TYPE REF TO IF_IXML,
W_STRING TYPE XSTRING,
W_SIZE TYPE I,
W_RESULT TYPE I,
W_LINE TYPE STRING,
IT_XML TYPE DCXMLLINES,
S_XML LIKE LINE OF IT_XML,
W_RC LIKE SY-SUBRC.
DATA: XML TYPE DCXMLLINES.
DATA: RC TYPE SY-SUBRC,
BEGIN OF XML_TAB OCCURS 0,
D LIKE LINE OF XML,
END OF XML_TAB.
data : l_element type ref to if_ixml_element,
xml_ns_prefix_sf type string,
xml_ns_uri_sf type string.
CLASS CL_IXML DEFINITION LOAD.
G_IXML = CL_IXML=>CREATE( ).
CHECK NOT G_IXML IS INITIAL.
M_DOCUMENT = G_IXML->CREATE_DOCUMENT( ).
CHECK NOT M_DOCUMENT IS INITIAL.
CALL FUNCTION 'SDIXML_DATA_TO_DOM'
EXPORTING
NAME = 'REPAIRDATA'
DATAOBJECT = IT_FINAL_LAST1[]
IMPORTING
DATA_AS_DOM = L_DOM
CHANGING
DOCUMENT = M_DOCUMENT
EXCEPTIONS
ILLEGAL_NAME = 1
OTHERS = 2.
CHECK NOT L_DOM IS INITIAL.
W_RC = M_DOCUMENT->APPEND_CHILD( NEW_CHILD = L_DOM ).
*Start of code for Header
* namespace
t_mnr = sy-datum+4(2).
CALL FUNCTION 'IDWT_READ_MONTH_TEXT'
EXPORTING
LANGU = 'E'
MONTH = t_mnr
IMPORTING
T247 = wa_t247
concatenate sy-datum+6(2)
wa_t247-ktx
sy-datum(4) into t_var1.
concatenate sy-uzeit(2)
sy-uzeit+2(2)
sy-uzeit+4(2) into t_var2.
clear : xml_ns_prefix_sf,
xml_ns_uri_sf.
l_element = m_document->get_root_element( ).
xml_ns_prefix_sf = 'TIMESTAMP'.
concatenate t_var1 t_var2 into xml_ns_uri_sf separated by space.
clear : t_var1,
t_var2,
t_mnr,
wa_t247.
l_element->set_attribute( name = xml_ns_prefix_sf
namespace = ' '
value = xml_ns_uri_sf ).
clear : xml_ns_prefix_sf,
xml_ns_uri_sf.
xml_ns_prefix_sf = 'FILECREATOR'.
xml_ns_uri_sf = 'SAP'.
l_element->set_attribute( name = xml_ns_prefix_sf
namespace = ' '
value = xml_ns_uri_sf ).
clear : xml_ns_prefix_sf,
xml_ns_uri_sf.
xml_ns_prefix_sf = 'CLAIMGROUP'.
xml_ns_uri_sf = '1'.
l_element->set_attribute( name = xml_ns_prefix_sf
namespace = ' '
value = xml_ns_uri_sf ).
clear : xml_ns_prefix_sf,
xml_ns_uri_sf.
xml_ns_prefix_sf = 'CLAIMTYPES'.
xml_ns_uri_sf = 'W'.
l_element->set_attribute( name = xml_ns_prefix_sf
namespace = ' '
value = xml_ns_uri_sf ).
*End of Code for Header
CALL FUNCTION 'SDIXML_DOM_TO_XML'
EXPORTING
DOCUMENT = M_DOCUMENT
IMPORTING
XML_AS_STRING = W_STRING
SIZE = W_SIZE
TABLES
XML_AS_TABLE = IT_XML
EXCEPTIONS
NO_DOCUMENT = 1
OTHERS = 2.
LOOP AT IT_XML INTO XML_TAB-D.
APPEND XML_TAB.
ENDLOOP.
*Start of Code for File name
concatenate p_file
'\R'
'000_119481'
sy-datum+6(2) sy-datum+4(2) sy-datum+2(2)
sy-uzeit(2) sy-uzeit+2(2) sy-uzeit(2) '.xml' into p_file.
*End of Code for File name
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
BIN_FILESIZE = W_SIZE
FILENAME = p_file
FILETYPE = 'BIN'
TABLES
DATA_TAB = XML_TAB
EXCEPTIONS
OTHERS = 10.
IF SY-SUBRC = 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF. -
Debugging ECC6: how to see the fields name when download internal table?
When we debug a reprot in ECC6 and save to a local file an internal table, the fields are not appearing only the data,
Is there a way to download also the table fields name?From the new debugger switch to the classic debugger using menu path Debugger->Switch to Classic Debugger. Form the classic debugger you can download internal table data with column name(s).
Regards,
Joy. -
How to download internal table data to excel in WebUI
Hi everyone,
I am trying to download the contents of an internal table to excel in CRM Web UI.
One way, would be to create a table view and use the export to excel button.
However, wish to avoid this and directly download using code.
Also tried converting to xstring and setting data in the response object. However, this works only when I execute the component directly from BSP_WD_CMPWB. In the UI framework however, when I click on custom button(for download), it navigates to a screen where the contents of string are shown directly on browser.
Is there any other way of doing this?
Thanks in advance.
Regards,
DeepakHi,
there are two ways to download excel from the webclient using table views. The first is a XML stream that is send to Excel directly. Only works for Excel 2003 and later. The second is the fall back to a .csv.
I do not know if for the second option a direct connection is established as mentioned in the last post or there is actually a file stream send to the client.
Anyway the SAP provides the excel download through a seperate webservice. Have a look at CL_CHTMLB_CONFIG_TAB_EXCEL_EXP->IF_HTTP_EXTENSION~HANDLE_REQUEST( ).
I suppose going the same direction with your excel download will work. This service opens a new download stream with the excel content... Maybe it is even possible to copy it and adjust it to your needs...
cheers Carsten -
How to download internal table to excel sheet
I have a requirement to download nearly 8 to 10 internal tables to excel sheets(for each internal table one excel sheet) without displaying the diolog box showing open and save buttons.
scenario :
I will enter the path name like this - C:\myfolder\Custom_programs.xls.
C:\myfolder\Custom_tables.xls.
(File name does not exit..it has to created inside the
specified folder)
in submit button I populate 2 internal tables say it1 and it2. then I need to move the tables contents to the path I have specified above.
attach_file_to_response method is not working for the above reqt since it is showing the dialog box.
Please provide a suitable solution...Please ignore all the responders that are stating that you can use GUI_DOWNLOAD from Web Dynpro ABAP. As you found out, this absolutely will not work, since this function module and other download logic like it depends upon a connection to the SAPGUI. People posting to use the GUI_DOWNLOAD from WDA need to learn a little more about the architecture of WDA before they go posting incorrect repsonses in the forum. I have little tollerance for people posting outright incorrect information in the WDA Forum.
What you want to do - download silent - is not easily done from WDA. There are rules about how web applications must behave in a browser. Normal HTML/JavaScript does not allow silent downloads for security reasons. Obviously there are many untrustworthy websites on the internet that you wouldn't want to allow to directly access your local machine. WDA must live within these same browser limitations.
SAP has done some work using a Java Applet to get around some of these security issues. This funcitonality comes in NetWeaver 7.01. It is the AcfUpDownload UI element:
http://help.sap.com/saphelp_nw70ehp1/helpdata/en/47/b9157c878a2d67e10000000a42189c/frameset.htm
However it is designer for usage with the Content or KPro server - so even it might not meet your needs. -
Download Internal Table into a Text File in BSP?
I have an internal table which i need to download into my local pc. I know i can not use FM gui_download. Could some one please post code on how to download the internal table into a text file in BSP. Also i am not sure if i can use save dialog FM. Also need suggestion on which FM to use for save dialog which tells where to save the file.
Any help will be appreciated.
Thanks
NahmanThis might be a good starting point.
<a href="/people/thomas.jung3/blog/2004/09/02/creating-a-bsp-extension-for-downloading-a-table">/people/thomas.jung3/blog/2004/09/02/creating-a-bsp-extension-for-downloading-a-table</a> -
Download internal table from BSP application to C:\ drive of the user
Hi,
How do we download a internal table data from a BSP application to the C:\ drive of the user. Have tried GUI Download, but it doesn't work. Also don't want a pop up to appear while this is happening. The code has to there in 'OnInputProcessing' event.
Regards,
JaisonHi Raja,
I went through few of the blogs and wrote the below code for downloading data. My requirement is that in the InputProcessing event i need to write a subset of data to the users C:\ drive. But even after doing the below change i'm unable to get the requirement done. Can you please tell me as to what i'm missing. I'm new to BSP development and help would be highly appreciated.
if not it_messages1[] is initial.
clear wa_messages1.
loop at it_messages1 into wa_messages1.
clear temp_string.
concatenate wa_messages1-PROJECT wa_messages1-FILENAME.......
into temp_string separated by CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
concatenate main_string temp_string into main_string separated by
CL_ABAP_CHAR_UTILITIES=>CR_LF.
endloop.
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
TEXT = main_string
MIMETYPE = 'APPLICATION/MSEXCEL;charset=utf-16le'
ENCODING =
IMPORTING
BUFFER = xmain_string.
EXCEPTIONS
FAILED = 1
OTHERS = 2
CALL METHOD cl_bsp_utility=>download
EXPORTING
object_s = xmain_string
content_type = 'APPLICATION/MSEXCEL;charset=utf-16le'
content_disposition = 'attachment;filename=test.xls'
response = mresponse
navigation = navigation.
Edited by: Jaison Yohannan on Jun 3, 2009 2:16 PM -
Function Module to Download Internal table in EXCEL
Hi All,
I need a Function Module to download the Internal table to Excel File.
I Have used SAP_CONVERT_TO_XLS_FORMAT,
but this function modules are using GUI_Download indirectly.
I dont want to use GUI_DOWNLOAD as i am going to call this Function Module in Portal.
So pls anybody has this type of function module.
Thanks & Regards,
Dhruv ShahHello Dhruv.
In Agreement with Deniz.
It is required to Export the query as an excel file.
[SAP HELP Library - Standard Reference - Exporting as a CSV File / MS Excel 2000 File|http://help.sap.com/saphelp_nw04/helpdata/en/d2/11a28fc26d4042a6d230a9783152f2/content.htm]
[SDN - Reference - Error in "Export to Microsoft Excel" from Portal|Error in "Export to Microsoft Excel" from Portal;
Hope this works out well.
Good Luck & Regards.
Harsh Dave -
Download internal table in debugger
All,
I have an internal table with 700,000 records. In debugging mode, I want to download that as a text file. How to achieve this.
Thanks,
SalilHi Salil Vaidya,
Go to Debug Mode of your program
Open the Content of the internal table which you want to download as text file
Then Right Click on Table Name or Table Content
Select SAVE TO LOCAL File
Select Data Format whichever you want..
Press Enter
Save As Dialog box will come... Give File name and save it anywhere you want..
Your data will be there in that file...
Text file may not be having limit..
If you are downloading to Excel then it depend's on the version
Excel 2007 supports more then 1 million records
but older versions are not supporting those many records..
Hope it will solve your problem..
Thanks & Regards
ilesh 24x7
ilesh Nandaniya -
Download internal table in XML format
Hi experts,
I want to download an internal table into an XML format.
How can I achieve this?
I have used the GUI_DOWNLOAD earlier for XLS purpose, will that work in this case too?
Thanks,
Ajay.Hi Ajay,
You can use the below format
DATA : gs_xml TYPE lvc_t_fccl.
(Fill lt_Table here)
TRY.
CALL TRANSFORMATION id SOURCE root = lt_Table
RESULT XML gs_xml.
CATCH cx_st_error.
ENDTRY.
Then Call GUI_DOWNLOAD, passing gs_XML as data_tab and filetype = BIN
Note : GUI_DOWNLOAD will not work in background.
Hope this solves your problem
Regards,
Seema -
Download Internal Table in CSV format it gets downloaded in single column
Hi All
I am converting Internal Table in CSV format using the FM CONVERT TO CSV FORMAT and then downloading data using GUI_DOWNLOAD FM.
I have given separator as ','.
However when I download the data the file is opened in Excel and first 2 to 3 column are merged in to single column and there was separator shown ';'.
How to overcome this problem.
AmolhI..,
Check this code..
<b>
It first downloads the data in internal table to a CSV format file..
and then uploads the same data into another internal table and prints it..</b>
analyze this and use accordingly..
tables:
spfli.
field-symbols : <fs>, <fs1>.
data:
w_line(1000),
w_field(20) type c,
wa_spfli type spfli.
data:
begin of fs_spfli,
carrid type spfli-carrid,
connid type spfli-connid,
countryfr type spfli-countryfr,
countryto type spfli-countryto,
fltime type spfli-fltime,
end of fs_spfli.
data :
t_file like standard table
of w_line
initial size 0.
data:
t_spfli like
standard table
of fs_spfli
initial size 0.
data:
t_spfli_up like
standard table
of fs_spfli
initial size 0.
select carrid
connid
countryfr
countryto
fltime
into corresponding fields of table t_spfli
from spfli.
loop at t_spfli into fs_spfli.
do.
assign component sy-index of structure fs_spfli to <fs>.
if sy-subrc ne 0.
exit.
endif.
w_field = <fs>.
condense w_field no-gaps.
if sy-index eq 1.
w_line = w_field.
else.
concatenate w_line ',' w_field into w_line.
endif.
enddo.
append w_line to t_file.
endloop.
call function 'GUI_DOWNLOAD'
exporting
BIN_FILESIZE =
filename = 'D:\file.txt'
filetype = 'ASC'
APPEND = ' '
write_field_separator = ' '
header = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
IMPORTING
FILELENGTH =
tables
data_tab = t_FILE
FIELDNAMES =
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.
clear t_FILE.
call function 'GUI_UPLOAD'
exporting
filename = 'D:\file.txt'
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
VIRUS_SCAN_PROFILE =
IMPORTING
FILELENGTH =
HEADER =
tables
data_tab = t_FILE
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
clear fs_spfli.
*constants :
*C_HTAB value CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
loop at t_file into w_line.
do.
if w_line eq space.
exit.
endif.
split w_line at ',' into w_field w_line.
condense w_field no-gaps.
assign component sy-index of structure fs_spfli to <fs>.
<fs> = w_field.
enddo.
append fs_spfli to t_spfli_up.
endloop.
loop at t_spfli_up into fs_spfli.
do.
assign component sy-index of structure fs_spfli to <fs>.
if sy-subrc ne 0.
exit.
endif.
write <fs>.
enddo.
skip.
endloop.
reward if it helps u..
sai ramesh -
Download internal table to Excel sheet
Hi,
I am trying a sampole program to download an internal table to excel and am
uisng the Fm GUI_DOWNLOAD for the same. But how do I ensure that each column
of internal will be aligned as columns in the excel sheet to. I a trying to do
that with a separator but I am not able to figure out.
Below is my code.
REPORT z_excel_download.
DATA : it_mara TYPE STANDARD TABLE OF mara WITH HEADER LINE.
DATA : BEGIN OF it_file OCCURS 0,
data(2000),
END OF it_file.
SELECT * FROM mara INTO TABLE it_mara UP TO 100 ROWS.
LOOP AT it_mara.
CONCATENATE it_mara-matnr
it_mara-ersda
it_mara-ernam
it_mara-pstat
it_mara-mtart
it_mara-mbrsh INTO it_file-data SEPARATED BY '/t'.
APPEND it_file.
ENDLOOP.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
filename = 'C:\Documents and Settings\XXXXXX\Desktop\test.xls'
TABLES
data_tab = it_file
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.Hi Varun,
On SDN are plenty of post where you can find the answer to your problem.
Please try the following code that I found here several years ago to resolve your problem.
Regards,
Eric
REPORT Excel.
TABLES:
sflight.
* header data................................
DATA :
header1 LIKE gxxlt_p-text VALUE 'Suresh',
header2 LIKE gxxlt_p-text VALUE 'Excel sheet'.
* Internal table for holding the SFLIGHT data
DATA BEGIN OF t_sflight OCCURS 0.
INCLUDE STRUCTURE sflight.
DATA END OF t_sflight.
* Internal table for holding the horizontal key.
DATA BEGIN OF t_hkey OCCURS 0.
INCLUDE STRUCTURE gxxlt_h.
DATA END OF t_hkey .
* Internal table for holding the vertical key.
DATA BEGIN OF t_vkey OCCURS 0.
INCLUDE STRUCTURE gxxlt_v.
DATA END OF t_vkey .
* Internal table for holding the online text....
DATA BEGIN OF t_online OCCURS 0.
INCLUDE STRUCTURE gxxlt_o.
DATA END OF t_online.
* Internal table to hold print text.............
DATA BEGIN OF t_print OCCURS 0.
INCLUDE STRUCTURE gxxlt_p.
DATA END OF t_print.
* Internal table to hold SEMA data..............
DATA BEGIN OF t_sema OCCURS 0.
INCLUDE STRUCTURE gxxlt_s.
DATA END OF t_sema.
* Retreiving data from sflight.
SELECT * FROM sflight
INTO TABLE t_sflight.
* Text which will be displayed online is declared here....
t_online-line_no = '1'.
t_online-info_name = 'Created by'.
t_online-info_value = 'SURESH KUMAR PARVATHANENI'.
APPEND t_online.
* Text which will be printed out..........................
t_print-hf = 'H'.
t_print-lcr = 'L'.
t_print-line_no = '1'.
t_print-text = 'This is the header'.
APPEND t_print.
t_print-hf = 'F'.
t_print-lcr = 'C'.
t_print-line_no = '1'.
t_print-text = 'This is the footer'.
APPEND t_print.
* Defining the vertical key columns.......
t_vkey-col_no = '1'.
t_vkey-col_name = 'MANDT'.
APPEND t_vkey.
t_vkey-col_no = '2'.
t_vkey-col_name = 'CARRID'.
APPEND t_vkey.
t_vkey-col_no = '3'.
t_vkey-col_name = 'CONNID'.
APPEND t_vkey.
t_vkey-col_no = '4'.
t_vkey-col_name = 'FLDATE'.
APPEND t_vkey.
* Header text for the data columns................
t_hkey-row_no = '1'.
t_hkey-col_no = 1.
t_hkey-col_name = 'PRICE'.
APPEND t_hkey.
t_hkey-col_no = 2.
t_hkey-col_name = 'CURRENCY'.
APPEND t_hkey.
t_hkey-col_no = 3.
t_hkey-col_name = 'PLANETYPE'.
APPEND t_hkey.
t_hkey-col_no = 4.
t_hkey-col_name = 'SEATSMAX'.
APPEND t_hkey.
t_hkey-col_no = 5.
t_hkey-col_name = 'SEATSOCC'.
APPEND t_hkey.
t_hkey-col_no = 6.
t_hkey-col_name = 'PAYMENTSUM'.
APPEND t_hkey.
* populating the SEMA data..........................
t_sema-col_no = 1.
t_sema-col_typ = 'STR'.
t_sema-col_ops = 'DFT'.
APPEND t_sema.
t_sema-col_no = 2.
APPEND t_sema.
t_sema-col_no = 3.
APPEND t_sema.
t_sema-col_no = 4.
APPEND t_sema.
t_sema-col_no = 5.
APPEND t_sema.
t_sema-col_no = 6.
APPEND t_sema.
t_sema-col_no = 7.
APPEND t_sema.
t_sema-col_no = 8.
APPEND t_sema.
t_sema-col_no = 9.
APPEND t_sema.
t_sema-col_no = 10.
t_sema-col_typ = 'NUM'.
t_sema-col_ops = 'ADD'.
APPEND t_sema.
CALL FUNCTION 'XXL_FULL_API'
EXPORTING
* DATA_ENDING_AT = 54
* DATA_STARTING_AT = 5
filename = 'TESTFILE'
header_1 = header1
header_2 = header2
no_dialog = 'X'
no_start = ' '
n_att_cols = 6
n_hrz_keys = 1
n_vrt_keys = 4
sema_type = 'X'
* SO_TITLE = ' '
TABLES
data = t_sflight
hkey = t_hkey
online_text = t_online
print_text = t_print
sema = t_sema
vkey = t_vkey
EXCEPTIONS
cancelled_by_user = 1
data_too_big = 2
dim_mismatch_data = 3
dim_mismatch_sema = 4
dim_mismatch_vkey = 5
error_in_hkey = 6
error_in_sema = 7
file_open_error = 8
file_write_error = 9
inv_data_range = 10
inv_winsys = 11
inv_xxl = 12
OTHERS = 13
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. -
Download internal table data into excel sheet with column heading and data
Hi,
I am having one internal table with column headings and other table with data.
i want to download the data with these tables into an excel sheet.
It should ask the user for file name to save it on their own name. They should give the file name in runtime and it should be downloaded into an excel sheet.
Can anyone tell what is the right function module for downloading these two internal table data with column heading and data.
what we have to do for storing the file name in runtime.
Can anyone help me on this.
Thanks,
Rose.Hi Camila,
Try this
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = PATH2
FILETYPE = 'XLS'
TABLES
DATA_TAB = IT_DATA
FIELDNAMES = IT_HEADINGS
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
Maybe you are looking for
-
How to connect my Mac book Pro to a TV
How to connect my MacBook Pro to the TV using HDTV cable
-
MIRO and change Alternative Reconciliation Account
Hi Experts: I'm trying to change the account on MIRO Tx. wich a Alternative Reconciliation account. I was testing LMR1M001 User Exit but It didn't work. Do you know any way that it can work? Thanks in advance.
-
IPod 80Gb-I convert video to ipod but doesnt have any sound
I just bought the 80Gb ipod and i am trying to sync from my pc to my ipod all of the videos i have. at the begining someone told me it was a version problem with quicktime or itunes, so i downloaded everything in the lates versions and tryied to conv
-
Issue with UTL FILE, does not read directory path
Hi Guys I have created a procedure using a UTL_File, but when I execute that procedure, it comes with an invalid directory path. create directory r_bmw as 'C:\BMW'; grant read, write on directory r_bmw to bmw; The above have been created successfully
-
Can't update, HD is being used by Time Machine
I get the message that the Hard Drive can't be used because it's being used by Time Machine. Time Machine is turned off. Following advice on another thread I deleted a TM pref file, restarted, and selected none (which wasn't there previously). I have