on 04-20-2009 9:07 AM
Hello Experts
I have a following request which seems to be giving some headaches.
I need to export results from one of the Web Dynpro reports (ABAP) I have developed to the Excel spreadsheet. Results are stored on ALV component. Request is to add header to export file with additional information like report title, selection criteria, date when report has been executed. By default export file contains only column names and data. I have set the header for ALV grid with all extra information I need to be passed to Excel file but it does not seem to be transferred at all.
At the moment I see 2 possible solutions: 1) write my own Excel export 2) use PDF export where it is possible to set header/footer text. None of these solutions are ideal, I'd rather set header in standard Excel export. Is that even possible? Please help.
Regards
Michael
Edited by: Soltuion Manager on Apr 20, 2009 10:08 AM
Edited by: Soltuion Manager on Apr 20, 2009 10:26 AM
The ALV export to Excel is pretty much as you see it. I don't believe there is any other way to influence it. You will likely have to fall back on one of your two options - custom Excel export or PDF. In NetWeaver 7.0 Enhancement Package 2 we are adding a new option to the ALV export - Crystal Reports. It, like the PDF exporter, does allow you to set the report headers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Looks like I was wrong. There are some API methods for controlling additional information export to Excel. I'm not sure if it came in later support packages or even in the 7.01 Enhancement package - but here is the help document on it:
http://help.sap.com/saphelp_nw70ehp1/helpdata/en/43/27b71e177e6020e10000000a422035/frameset.htm
Thomas
Thanks a bunch for your suggestion. I have tried these methods before even creating this message but it does not seem to work. I am not sure what would be the definition of design objects here but none of the headers I have created (header of ALV grid and header for PDF document) are not being copied to Excel sheet.
Kind Regards
Michael
Uday
After over 2 weeks of waiting for other suggestions I finally gave up. Today I have developed couple of routines which does pretty much what you have suggested but instead of "hard-coding" types I have made it dynamic so I can easily implement it on all WebDynpro ALV grids. I have also added routine which collects all entries from select options and list them in the header of Excel export so users will clearly see what were the selection criteria (especially important if reports are passed around via email etc). It is pity that SAP does not provide this kind of functionality as a standard. Anyway - thanks a bunch for any suggestions.
Kind Regards
Michael
Hello Michael,
I haven't tried using the builtin functionality of ALV to achieve a similar fnctionality as yours but can suggest you a workaround for that. As how you might be already knowing you can try using the CL_WD_RUNTIME_SERVICES=>attach_file_to_response to download the contents into Excel/notepad/word. So just can modify the internal table to contain the extra information that you need. You can use the approach below for using the attach_file_to_response method:
1) First read the table's data into an internal table.
2) Convert the internal table data to STRING format.
3) Now convert it into tab separated format as how desired.
4) Convert this STRING format to XSTRING format
5) Make use of the attach_file_to_response method.
Regards,
Uday
METHOD onactionon_submit .
DATA: lv_node TYPE REF TO if_wd_context_node,
lt_mara TYPE if_main=>elements_mara,
wa_mara TYPE if_main=>element_mara,
lead_selection_index TYPE i,
mara_string TYPE string,
mara_xstring TYPE xstring.
lv_node = wd_context->get_child_node( name = 'MARA' ).
CALL METHOD lv_node->get_static_attributes_table
IMPORTING
table = lt_mara.
LOOP AT lt_mara INTO wa_mara.
CONCATENATE mara_string
wa_mara-matnr
wa_mara-ersda
wa_mara-ernam
wa_mara-matkl
wa_mara-meins
cl_abap_char_utilities=>cr_lf INTO mara_string
SEPARATED BY cl_abap_char_utilities=>horizontal_tab.
ENDLOOP.
** Now you need to add the column headers & the desired extra information through coding to
** mara_string
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = mara_string
IMPORTING
buffer = mara_xstring.
CL_WD_RUNTIME_SERVICES=>attach_file_to_response( i_filename = 'TEMP.XLS'
i_content = mara_xstring
i_mime_type = 'EXCEL' ).
ENDMETHOD.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Uday
Thanks for your suggestion but as I mentioned it is not ideal solution here (I donu2019t want to re-invent the wheel if it is not necessary). I used ALV component hoping that it will accommodate all basic needs without having to do custom coding. If it will turn out that there is no way to set header in standard Excel export I will have to write my own export or use PDF export. I will wait and see if someone else will come up with other ideas.
Regards
Michael
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.