Internal table to be downloaded into excel is empty
Hi everybody,
I created a page where I'm displaying in a table all the records. OnInitialization, I set my RFC needed to get the data from the Prod.Server and so far is displaying fine the data when I test it.
Now, I want to download that table into excel so I created a buttom in the Layout and in the same page OnInputProcessing I'm checking the event (IF event_id = CL_HTMLB_MANAGER=>EVENT_ID) to check if the new button was trigered. Next, I copied the solution given by Thomas in the weblogs "BSP Download to Excel in Unicode Format" but when I check my table already displayed and needed by the function 'SCMS_STRING_TO_XSTRING', now is empty.
I set the Automatic Page Attribute for my table ON but still is empty.
Do I have to set something else to retain or get my table OnInputProcessing?
Thanks in advance for your quick answer.
Juan
Thanks everybody for your quick answers.
You are all rights, when I set my page Stateful it solve my problem and I'm getting my table with Data.
Now, I'm having a second problem.
As I told you before, I only have one page where in OnInitialization I'm displaying a table, that's fine. I include a button to download the table into excel and I copied the Thomas code into the same page OnInputProcessing Event. I test it in debug mode and it's going fine thrue all the statements: executing the Funtion 'SCMS_STRING_TO_XSTRING' and executing the following statements response->set_header_field and so on..
The problem is when getting the last statement:
response->set_data( data = l_xstring
length = l_len ).
navigation->response_complete( ).
My current page becomes blank with no dialog to download the file.
Here is my code from OnInputProcessing event, sorry for the long message.
CLASS CL_HTMLB_MANAGER DEFINITION LOAD.
DATA: WA LIKE LINE OF ZIMSLOC.
DATA: UNRESTQ(17) TYPE C,
KLABS(17) TYPE C.
data: name(60) type C,
l_string type STRING,
l_xstring type XSTRING,
l_len type I,
APP_TYPE(60) type C.
DATA: response TYPE REF TO if_http_response.
create object response type cl_http_response exporting add_c_msg = 1.
constants: crlf type string value cl_abap_char_utilities=>cr_lf,
tab type string value cl_abap_char_utilities=>horizontal_tab.
Optional: test that this is an event from HTMLB library.
IF event_id = CL_HTMLB_MANAGER=>EVENT_ID.
See if download is triggered from button
DATA: event TYPE REF TO CL_HTMLB_EVENT.
event = CL_HTMLB_MANAGER=>get_event( runtime->server->request ).
IF event->name = 'button' AND event->event_type = 'click'.
DATA: button_event TYPE REF TO CL_HTMLB_EVENT_BUTTON.
button_event ?= event.
ENDIF.
CASE event->id.
WHEN 'download'.
LOOP AT zimsloc INTO WA.
UNRESTQ = WA-UNRESTRICTEDQ.
KLABS = WA-KLABS.
CONCATENATE l_string
WA-WERKS tab
WA-MATNR tab
WA-CHARG tab
WA-LICHA tab
WA-MAKTX tab
KLABS tab
UNRESTQ tab
WA-SOBKZ tab
WA-SONUM tab
WA-MEINS tab
crlf
INTO l_string SEPARATED BY SPACE.
ENDLOOP.
APP_TYPE = 'APPLICATION/MSEXCEL; charset=utf-16le'.
call function 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = l_string
MIMETYPE = APP_TYPE
IMPORTING
BUFFER = l_xstring.
Add the Byte Order Mark - UTF-16 Little Endian
concatenate cl_abap_char_utilities=>byte_order_mark_little
l_xstring
into l_xstring in byte mode.
response->set_header_field( name = 'content-type'
value = 'APPLICATION/MSEXCEL; charset=utf-16le' ).
some Browsers have caching problems when loading Excel format
response->delete_header_field( name =
if_http_header_fields=>cache_control ).
response->delete_header_field( name =
if_http_header_fields=>expires ).
response->delete_header_field( name =
if_http_header_fields=>pragma ).
start Excel viewer either in the Browser or as a separate window
response->set_header_field( name = 'content-disposition' value =
'attachment; filename=webforms.xls' ).
finally display Excel format in Browser
l_len = xstrlen( l_xstring ).
response->set_data( data = l_xstring
length = l_len ).
navigation->response_complete( ).
WHEN others.
ENDCASE.
ENDIF.
Thanks againg for your help.
Juan
Similar Messages
-
Downloading into excel file , the is alignment is out
The reports when downloading into excel file is not what we usually getting. The alignment is out.
Hi Basavaraj,
When you are creating dynamic internal table(itab1) and fields of internal table, at the same time in the same way create one more internal table(itab2) resrict this up to 10 columns.
now
DATA : num type i,
FNAME(255) TYPE C
VALUE '/data/sapdata/filename'.
CONSTANTS : C_COMMA TYPE C VALUE ','.
DATA : BEGIN OF I_DISPLAY OCCURS 0,
REC(400),
END OF I_DISPLAY.
loop at itab1
num = num + 1.
if num le 100.
move-corresponding fields to itab2
else.
exit.
endif.
endloop.
Give column headings
itab2-col1 = 'name1'
itab2-col2 = 'name2'
itab2-col3 = 'name3'
itab2-col4 = 'name4'
itab2-col5 = 'name5'
itab2-col6 = 'name6'
itab2-col7 = 'name7'
itab2-col8 = 'name8'
itab2-col9 = 'name9'
itab2-col10 = 'name10'
INSERT itab2 INDEX 1.
CLEAR itab2.
loop itab2.
CONCATENATE
itab2-col1
itab2-col2
itab2-col3
itab2-col4
itab2-col5
itab2-col6
itab2-col7
itab2-col8
itab2-col9
itab2-col10
into I_DISPLAY-REC SEPARATED BY C_COMMA.
APPEND I_DISPLAY.
CLEAR I_DISPLAY.
ENDLOOP.
OPEN DATASET FNAME FOR OUTPUT IN TEXT MODE.
LOOP AT I_DISPLAY.
TRANSFER I_DISPLAY TO FNAME.
ENDLOOP.
CLOSE DATASET FNAME.
endloop. -
Downloading different internal table data in a single excel with diff tabs.
Hi gurs,
I have 4 internal tables with me i can able to display in 4 different excel sheets using CALL FUNCTION 'EXCEL_OLE_STANDARD_DAT'
But my requirement is i want to download 4 internal table in single excel sheets with different tabs. please send the code if u have.
Thanks and regards.Hi,
If you want to display the content of 4 internal table in different sheets of same workbook then go through below code,
DATA : EXCEL TYPE OLE2_OBJECT,
WORKBOOKS TYPE OLE2_OBJECT,
WORKBOOK TYPE OLE2_OBJECT,
CELLS TYPE OLE2_OBJECT,
SHEET TYPE OLE2_OBJECT,
FONT TYPE OLE2_OBJECT,
H_COM1 TYPE OLE2_OBJECT,
F TYPE RLGRAP-FILENAME,
FILEP TYPE DRAW-FILEP,
G_FILE_DEST TYPE STRING,
G_FILE_TEMP TYPE STRING,
G_SYSUBRC TYPE SY-SUBRC,
G_FILE_SRC TYPE DRAW-FILEP.
START THE EXCEL APPLICATION
CREATE OBJECT excel 'EXCEL.APPLICATION'.
CALL METHOD OF excel 'WORKBOOKS' = workbooks.
SET PROPERTY OF excel 'VISIBLE' = 0.
CALL METHOD OF workbooks 'OPEN' EXPORTING
#1 = filep.
For Sheet1
CALL METHOD OF excel 'Worksheets' = sheet
EXPORTING #1 = 1.
CALL METHOD OF sheet 'Activate'.
FREE OBJECT sheet.
CALL METHOD OF excel 'CELLS' = cells
EXPORTING #1 = 1
#2 = 15.
SET PROPERTY OF cells 'VALUE' = <value>
CALL METHOD OF cells 'FONT' = font.
SET PROPERTY OF font 'SIZE' = '20'.
FREE OBJECT cells.
For Sheet2
CALL METHOD OF excel 'Worksheets' = sheet
EXPORTING #1 = 2.
CALL METHOD OF sheet 'Activate'.
FREE OBJECT sheet.
CALL METHOD OF excel 'CELLS' = cells
EXPORTING #1 = 1
#2 = 6.
SET PROPERTY OF cells 'VALUE' = 'XYZ'.
CALL METHOD OF cells 'FONT' = font.
SET PROPERTY OF font 'SIZE' = '20'.
GET PROPERTY OF excel 'ACTIVESHEET' = sheet.
CALL METHOD OF sheet 'SAVEAS' EXPORTING
#1 = <destination file path where you want to store>
#2 = 1.
CALL METHOD OF workbooks 'CLOSE'.
CALL METHOD OF excel 'QUIT'.
FREE OBJECT excel.
Thanks!
Brunda
'Reward if useful'. -
Hi All,
In a ALV report, i would like to donwload the final internal table into an excel sheet.
The requirement is that the data should be filled from 8th row of excel sheet.
I am using GUI_DOWNLOAD and it makes the data to dump from first line of excel sheet itself.
How to incorprate the logic for these requirements?
Your help will be sincerely appreciated.
Thanks in Advance,
Pavan
Edited by: Pavan Sanganal on Dec 16, 2008 10:51 AMHello Pavan,
I think you have written a separate sub-routine for this. Use another internal table IT_XLS which has a similar structure as the int. table for ALV display (IT_ALV, say).
Now try this piece of code:
DO 8 TIMES.
APPEND WA_XLS TO IT_XLS. "Populate 8 blank rows in the table
ENDDO.
LOOP AT IT_ALV INTO WA_ALV.
WA_XLS = WA_ALV.
APPEND WA_XLS TO IT_XLS.
CLEAR WA_XLS.
ENDLOOP.
Use GUI_DOWNLOAD to download IT_XLS. Can you please tell what do you want to populate in these 8 blank rows?
BR,
Suhas -
Hi all,
is there any function module which i can download the excel sheet into internal table.
I have requirement like this way.
i have two records in excel file like
a b c 10 100
a b c 20 100
I have to copy into internal table these values as it is and then I want to do calculations based on 10 & 20.
I am trying to do it with Field symbols but not able to do so.
LOOP AT INTERN1.
IF KZHEADER = 'X'
AND INTERN1-ROW = 1.
CONTINUE.
ENDIF.
TIND = INTERN1-COL.
CONCATENATE 'DATA_TAB-VALUE_' TIND INTO ZWFELD.
ASSIGN (ZWFELD) TO <fs1>.
<fs1> = INTERN1-VALUE.
AT END OF ROW.
APPEND DATA_TAB.
CLEAR DATA_TAB.
ENDAT.
ENDLOOP.
Any suggetions are really appreciatable.
shyleshHi,
FM : 'SXPG_COMMAND_EXECUTE'
For full program code check the following link:
http://www.sap-img.com/abap/download-in-background-in-excel-format.htm
Regards,
Bhaskar -
Function module to download into excel sheet in crm
Hi,
Needed the Function module to download the data from internal table into the excel sheet in the CRM
<b></b>use
FM :- GUI_DOWNLOAD
Example Code.
lv_file_name = 'c:abcd.xls'
*----Load Detail Report Data to Excel File
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = lv_file_name
filetype = 'DAT'
write_field_separator = 'X'
codepage = '4103'
TABLES
data_tab = lt_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.
:- lt_det_report---> is table for storing data .
it can be any type
<b>Please Reward Points & Mark Helpful Answers</b>
To mark Helpful Answers ;click radio Button next to the post.
RadioButtons
<b>o</b> Helpful Answer
<b>o</b> Very helpful Answer
<b>o</b> Problem Solved.
Click any of the above button next to the post; as per the anwers
<b>To close the thread; Click Probelm solved Radio Button next to the post , which u feel is best possible answers</b> -
Taking download into excel from ALV Grid - header is printing in two lines
Hi All,
I have a scenario where I am taking the download from ALV grid to an excel sheet. Now the header of the ALV (column names) is appearing in two lines in the downloaded excel sheet while items (records of the ALV table) are getting displayed in a single line.
This download is taken from the standard download to local file (spreadsheet) button provided by SAP for ALVs.
I am using function module "Reuse_alv_grid_display" for the purpose.
Can somebody provide an idea how I can avoid the header printing in two lines and keep the length as it is.
Thanks in Advance,
ChandanHi..
1. Pass header name in internal table appned first line.
2. after that pass u r data .
3. Use FM. WS_DOWNLOAD
Salil ......
Edited by: salil chavan on Nov 26, 2008 11:07 AM -
Data from dynamic internal table to be downloaded to App server
Dear Friends,
I have a a dynamically generated internal table and it contains huge data.And my requirement is to download the same data with a deliminator into a text file in application server.
Can you pls help me with the code....
Thanks,
jeevan.Hello Jeevan,
PFB a code snippet for your requirement:
DATA: v_dataset TYPE fileextern VALUE './test335.txt',
v_dref TYPE REF TO data,
v_data TYPE string.
FIELD-SYMBOLS: <itab> TYPE STANDARD TABLE,
<wa> TYPE ANY,
<val> TYPE ANY.
CREATE DATA v_dref TYPE STANDARD TABLE OF ('T001').
ASSIGN v_dref->* TO <itab>.
SELECT * FROM ('T001') INTO TABLE <itab> UP TO 20 ROWS.
OPEN DATASET v_dataset FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
CHECK sy-subrc = 0.
LOOP AT <itab> ASSIGNING <wa>.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE <wa> TO <val>.
IF sy-subrc = 0.
CONCATENATE v_data <val> INTO v_data SEPARATED BY ';'.
ELSE.
EXIT.
ENDIF.
ENDDO.
TRANSFER v_data TO v_dataset.
CLEAR v_data.
ENDLOOP.
CLOSE DATASET v_dataset.
@Others: The OP wants to add a delimiter to the fields of a dynamic table.
>
jeevan kumar wrote:
> I have a a dynamically generated internal table and it contains huge data.And my requirement is to download the same data with a deliminator into a text file in application server. -
Oracle Database Table data Load it into Excel
Hello All,
Please I need your help for this problem:
I need to load Oracle database Table data and load it into Excel and saved with xls format.
Example -Select * from Slase data load it into the Excel.
I appreciate ans sample code to help me do that, Please help me out. This is very urgent.
Thanks alot and best regards,
anbu>
I need to load Oracle database Table data and load it into Excel and saved with xls format.
Example -Select * from Slase data load it into the Excel.
I appreciate ans sample code to help me do that, Please help me out. This is very urgent.
>
Nothing in these forums is 'urgent'. If you have an urgent problem you should contact Oracle support or hire a consultant.
You have proven over and over again that you are not a good steward of the forums. You continue to post questions that you say are 'urgent' but rarely take the time to mark your questions ANSWERED when they have been.
Total Questions: 90 (78 unresolved)
Are you willing to make a commitment to to revisit your 78 unresolved questions and mark them ANSWERED if they have been?
The easiest way to export Oracle data to Excel is to use sql developer. It is a free download and this article by Jeff Smith shows how easy it is
http://www.thatjeffsmith.com/archive/2012/09/oracle-sql-developer-v3-2-1-now-available/
>
And One Last Thing
Speaking of export, sometimes I want to send data to Excel. And sometimes I want to send multiple objects to Excel – to a single Excel file that is. In version 3.2.1 you can now do that. Let’s export the bulk of the HR schema to Excel, with each table going to it’s own workbook in the same worksheet.
>
And you have previously been ask to read the FAQ at the top of the thread list. If you had done that you would have seen that there is a FAQ for links that have many ways, with code, to export data to Excel.
5. How do I read or write an Excel file?
SQL and PL/SQL FAQ -
KNA1 table records not downloading to excel correctly
Folks,
Im trying to download KNA1 table records into excel sheet. I can see total number of records in table as 22513, but when i download them into excel sheet then total records are coming to 22521.
When i dig the excel sheet for 4 customers record is present in 2 lines(where because of special characters data truncated to next line). However rest all customers are downloaded in single line.
What steps i need to follow to download that 4 records also into single line along with the special characters.
will be waiting for your valuable answers.
Regards
VEnk@No i checked in table all four records are unique no duplicates present.
-
ChartView and FilterView are overlapping whenever I download into Excel
Hi,
I have a report with chart view as well as filterview resides at the bottom of the chart.
Whenever am trying to download the report into Excel the Filterview is over lapping on the Chart View.
Can you guys please suggest how can i overcome this.
Thanks in advance,
PramodThis an extract from Oracle metalink..
This document is being delivered to you via Oracle Support's Rapid Visibility (RaV) process and therefore has not been subject to an independent technical review.
Applies to:
Answers, Interactive Dashboard - Version: 10.1.3.4.1 [1900] - Release: 10g
Information in this document applies to any platform.
Symptoms
When downloading reports that have multiple charts into Excel, the charts appear overlapping. The downloaded report(excel file) looks different from what it displayed in a dashboard.
Cause
There is a defect around downloading a request to excel that has multiple views on the report
This is as per a number of bugs already raised around this issue:
Bug 8825314: TABLE VIEW OVERLAPPED WITH CHART VIEW IN THE EXCEL SHEET
Bug 8478529: DOWNLOADED EXCEL SHEET HAS VIEWS THAT OVERLAP EACH OTHER
Bug 7700214: DOWNLOADING TO EXCEL OVERLAPS THE CHART WITH THE TABLE VIEW
Bug 7501223: DOWNLOADING TO EXCEL OVERLAPS THE CHART WITH THE PIVOT TABLE
Solution
The following bugs already raised to address this issue:
Bug 8825314: TABLE VIEW OVERLAPPED WITH CHART VIEW IN THE EXCEL SHEET
Bug 8478529: DOWNLOADED EXCEL SHEET HAS VIEWS THAT OVERLAP EACH OTHER
Bug 7700214: DOWNLOADING TO EXCEL OVERLAPS THE CHART WITH THE TABLE VIEW
Bug 7501223: DOWNLOADING TO EXCEL OVERLAPS THE CHART WITH THE PIVOT TABLE
Workaround at this stage would be to use download to html/powerpoint.
Hope this helps!
Regards.. -
Storing internal table from XML File into DDIC
Hi everybody,
im trying to store an internal table <b>without</b> knowing the content - means the structure (fields)- into th DDIC, but i failed. The code is:
DATA xslt_error TYPE REF TO cx_xslt_exception.
TRY .
perform load_file using 'D:/usr/YTGVF_asXML.xml' changing itab_XMLResult.
refresh itab_tableA.
call transformation id
source xml itab_XMLResult
result GREATEST = itab_tableA.
CATCH cx_xslt_exception INTO xslt_error.
DATA: xslt_message type string .
xslt_message = xslt_error->get_text( ).
write xslt_message.
ENDTRY.
form load_file
using path type localfile
changing tab type table.
data: s type string,
filelength type i.
s = path.
refresh tab.
call function 'GUI_UPLOAD'
exporting filename = s
filetype = 'BIN'
importing filelength = filelength
tables data_tab = tab
exceptions others = 1.
endform. "load_file
So, how can i store itab_tableA, without knowing the content (fields) of the table? The XML-File is of type asXML - i guess there should be a solution.
Thanks for all replies!
BG, JimAbsolutely, I don't see why that would be a problem.
After parsing through the schema or DTD, you would know what the structure of the XML file coming through would be. So it would be basically uploading the file to SAP and then parsing the schema or DTD file, you will come to know the structure of your XML.
And once you know the structure, you can create your <a href="/people/subramanian.venkateswaran2/blog/2004/11/19/dynamic-internal-table internal table</a>, and put the values from the XML file in the same.
Considering my limited knowledge in XML, I am not able to provide information regarding , if there are any function modules/classes which SAP supports to directly read an XML schema/DTD and create a table of that sort. But the above inputs should help you in your way...
Regards,
Subramanian V. -
WUO-712 : Webutil Error while downloading into Excel
Hello Everyone,
I have installed oracle Application server 10g (10.1.2.0.2) with webutill.
But while downloading data into Excel sheet it's through an error WUO-712 randomly due to which some of the data is missed out.
We have installed webutil 10.5 with forms and reports 10g.
Please suggest some solution for the same.
Please revert for the same ASAP.
Thanks in advance
Regards,
Ajinkya
Edited by: Ajinkya on Nov 3, 2009 10:45 PMPlease reply for this thread.......:)
-
Reg. Reports download into excel
Hello Everyone,
I have installed oracle Application server 10g (10.1.2.0.2) with webutill.
But while downloading data into Excel sheet it's through an error WUO-712 randomly due to which some of the data is missed out.
We have installed webutil 10.5 with forms and reports 10g.
Please suggest some solution for the same.
Please revert for the same ASAP.
Thanks in advance
Regards,
Ajinkyain report we are using local currency and parallel currency. one colum local currency and another colum parallel currency shwoing in report, but i transfer to excel shwoig following format.
account no local currency account no paraelll currency
we need following format in excel
account no local currency parellel currency
regards
JK Rao -
Chinese char disorder from SAP download into Excel
Hi all,
I used t_code PA30 to input one person name and the name is '燊'. But when I use customizing report to display and download the person information into Excel,
the display is ordinary and the person name is disorder in the downloaded excel.
the '燊' changed the interrogation mark.
But I use the customizing report to download the other information, that is ordinary.
I don't know the reason, and I hope everybody help me to resolve the error.
Thanks
Ma ChaoHi,
1. WS_DOWNLOAD is obsolete. use fm GUI_DOWNLOAD
For search and replace a character in string please check this code , may this will be useful to you
DATA : find(33) TYPE c VALUE 'xx_aa_yy_zz_xx_yy_yyb_yy_yybyy_1',
len LIKE sy-fdpos.
len = 1.
WRITE:/ find.
WHILE sy-subrc = 0.
SEARCH find FOR 'yy_' STARTING AT len.
CHECK sy-subrc = 0.
len = len + sy-fdpos + 1.
REPLACE '_' WITH '*' INTO find+len(1).
ENDWHILE.
WRITE:/ find.
aRs
Maybe you are looking for
-
My computer (Macbook) was working fine this am. I left it for an hour and then came back and the screen was black (always does that as the screensaver hardly ever works). I moved the mouse to wake it up and everything was normal. I went to adjust the
-
Three monitors on T520, Linux
Is it possible to use the internal monitor + two external monitors under Linux? Does this require that I enable the NVidia card, or is it possible if using only the Intel integrated graphics? The computer is a T520 with Intel integrated + NVidia grap
-
My HP Officejet J4580 printer makes a very loud rat-a-tat noise, then prints fine.
My HP Officejet J4580 printer makes a very loud rat-a-tat noise, then prints fine.
-
Old problem-- Electricity leak while charging MBP retinal display
I know this problem happened for long time since the early version of MBP. There is electricity leaking on the metal part of computer while you plug in the adaptor because the earth line is missing. If you use the extension cord, the problem is gone
-
Can I copy, email, or print out text messages?
I would like to save some text messages, & I'm wondering if they can be saved, emailed or printed?