Download alv output to an excel file
Dear experts,
I am using oops alv if i click file download button if i select anything except <b>spread sheet</b> it gives a short dump . Downloaded values are correct i want to know how to save it as a local file also to resolve for other options.
regards,
balaji
Hi Balaji,
Refer this link (Very helpful): http://www.****************/Tutorials/ALV/ColoredOutput/Program.htm
Multi-colored output of ALV in EXCEL
There would be many situations where we need to highlight some of the records in bold or different color depending on some value. In this document, we showcase how this can be achieved. Look at the screenshot of an excel sheet with different colors and bold in some cells.
Following is a demo program in achieving the same:
Report ZMULTICOLOR_TEST no standard page heading.
this report demonstrates how to send some ABAP data to an
EXCEL sheet using OLE automation.
include ole2incl.
handles for OLE objects
data: h_excel type ole2_object, " Excel object
h_mapl type ole2_object, " list of workbooks
h_map type ole2_object, " workbook
h_zl type ole2_object, " cell
h_f type ole2_object, " font
h_c type ole2_object. " color
DATA: FILENAME LIKE RLGRAP-FILENAME.
tables: spfli.
data h type i.
table of flights
data: it_spfli like spfli occurs 10 with header line.
*& Event START-OF-SELECTION
start-of-selection.
read flights
select * from spfli into table it_spfli.
display header
uline (61).
write: / sy-vline no-gap,
(3) 'Flg'(001) color col_heading no-gap, sy-vline no-gap,
(4) 'Nr'(002) color col_heading no-gap, sy-vline no-gap,
(20) 'Von'(003) color col_heading no-gap, sy-vline no-gap,
(20) 'Nach'(004) color col_heading no-gap, sy-vline no-gap,
(8) 'Zeit'(005) color col_heading no-gap, sy-vline no-gap.
uline /(61).
display flights
loop at it_spfli.
write: / sy-vline no-gap,
it_spfli-carrid color col_key no-gap, sy-vline no-gap,
it_spfli-connid color col_normal no-gap, sy-vline no-gap,
it_spfli-cityfrom color col_normal no-gap, sy-vline no-gap,
it_spfli-cityto color col_normal no-gap, sy-vline no-gap,
it_spfli-deptime color col_normal no-gap, sy-vline no-gap.
endloop.
uline /(61).
tell user what is going on
call function 'SAPGUI_PROGRESS_INDICATOR'
exporting
PERCENTAGE = 0
text = text-007
exceptions
others = 1.
start Excel
create object h_excel 'EXCEL.APPLICATION'.
PERFORM ERR_HDL.
set property of h_excel 'Visible' = 1.
CALL METHOD OF H_EXCEL 'FILESAVEAS' EXPORTING #1 = 'c:\kis_excel.xls' .
PERFORM ERR_HDL.
tell user what is going on
call function 'SAPGUI_PROGRESS_INDICATOR'
exporting
PERCENTAGE = 0
text = text-008
exceptions
others = 1.
get list of workbooks, initially empty
call method of h_excel 'Workbooks' = h_mapl.
perform err_hdl.
add a new workbook
call method of h_mapl 'Add' = h_map.
perform err_hdl.
tell user what is going on
call function 'SAPGUI_PROGRESS_INDICATOR'
exporting
PERCENTAGE = 0
text = text-009
exceptions
others = 1.
output column headings to active Excel sheet
perform fill_cell using 1 1 1 200 'Carrier id'(001).
perform fill_cell using 1 2 1 200 'Connection id'(002).
perform fill_cell using 1 3 1 200 'City from'(003).
perform fill_cell using 1 4 1 200 'City to'(004).
perform fill_cell using 1 5 1 200 'Dep. Time'(005).
loop at it_spfli.
copy flights to active EXCEL sheet
h = sy-tabix + 1.
if it_spfli-carrid cs 'AA'.
perform fill_cell using h 1 0 000255000 it_spfli-carrid.
elseif it_spfli-carrid cs 'AZ'.
perform fill_cell using h 1 0 168000000 it_spfli-carrid.
elseif it_spfli-carrid cs 'JL'.
perform fill_cell using h 1 0 168168000 it_spfli-carrid.
elseif it_spfli-carrid cs 'LH'.
perform fill_cell using h 1 0 111111111 it_spfli-carrid.
elseif it_spfli-carrid cs 'SQ'.
perform fill_cell using h 1 0 100100100 it_spfli-carrid.
else.
perform fill_cell using h 1 0 000145000 it_spfli-carrid.
endif.
if it_spfli-connid lt 400.
perform fill_cell using h 2 0 255000255 it_spfli-connid.
elseif it_spfli-connid lt 800.
perform fill_cell using h 2 0 077099088 it_spfli-connid.
else.
perform fill_cell using h 2 0 246156138 it_spfli-connid.
endif.
if it_spfli-cityfrom cp 'S*'.
perform fill_cell using h 3 0 155155155 it_spfli-cityfrom.
elseif it_spfli-cityfrom cp 'N*'.
perform fill_cell using h 3 0 189111222 it_spfli-cityfrom.
else.
perform fill_cell using h 3 0 111230222 it_spfli-cityfrom.
endif.
if it_spfli-cityto cp 'S*'.
perform fill_cell using h 4 0 200200200 it_spfli-cityto.
elseif it_spfli-cityto cp 'N*'.
perform fill_cell using h 4 0 000111222 it_spfli-cityto.
else.
perform fill_cell using h 4 0 130230230 it_spfli-cityto.
endif.
if it_spfli-deptime lt '020000'.
perform fill_cell using h 5 0 145145145 it_spfli-deptime.
elseif it_spfli-deptime lt '120000' .
perform fill_cell using h 5 0 015215205 it_spfli-deptime.
elseif it_spfli-deptime lt '180000' .
perform fill_cell using h 5 0 000215205 it_spfli-deptime.
else.
perform fill_cell using h 5 0 115115105 it_spfli-deptime.
endif.
endloop.
EXCEL FILENAME
CONCATENATE SY-REPID '_' SY-DATUM6(2) '_' SY-DATUM4(2) '_'
SY-DATUM(4) '_' SY-UZEIT '.XLS' INTO FILENAME.
CALL METHOD OF H_MAP 'SAVEAS' EXPORTING #1 = FILENAME.
free object h_excel.
perform err_hdl.
FORM FILL_CELL *
sets cell at coordinates i,j to value val boldtype bold *
form fill_cell using i j bold col val.
call method of h_excel 'Cells' = h_zl
exporting
#1 = i
#2 = j.
perform err_hdl.
set property of h_zl 'Value' = val .
perform err_hdl.
get property of h_zl 'Font' = h_f.
perform err_hdl.
set property of h_f 'Bold' = bold .
perform err_hdl.
set property of h_f 'Color' = col.
perform err_hdl.
endform. "FILL_CELL
*& Form ERR_HDL
outputs OLE error if any *
--> p1 text
<-- p2 text
form err_hdl.
if sy-subrc <> 0.
write: / 'OLE-Automation Error:'(010), sy-subrc.
stop.
endif.
endform. " ERR_HDL
Good Luck and thanks
AK
Similar Messages
-
To download alv output to two excel sheets because of large data
Hi all,
I want to download alv output to excel sheet,I know how to do,but the no of record is very large and can not be accomodated in one sheet.
can anyone please tell how to download it into two sheets or some other way.
I want excel format only.
Regards,
sudhahi sudha yadav,
right now i am working on the same issue.
what right i am doing is that,
i want to download an internal table it is containing more than 2 lakhs records but excel can accomidate 60000 records, so
before call gui download i am sending first 60000 records into another internal table with same time, by using append statemen and indexs,
that new internal table i am downloading
again i am repeating the same thing by using sy-tabix,
finally i am creating more than one excel file
by using oops concepts we can also create in one excel file no of work sheets
but its lengthy process so i am right now creating no of excel files only
if it is useful , pls rewards points to this answer -
Download ALV result list as excel-file in background job
Dear Experts,
I am looking for a possibily to download the result of an ALV based report as excel-file in a background job. Surely there is a standard function which can be used or at least some hints how to implement this. I searched the forum but couldn't find a thread which was covering this problem exactly.
Thanks in advance
BenjaminDear Mr. Krapf,
it is possible to output an ALV list to an Excel file in the background but there are some limitations.
Please consider the following notes:
#7925 Graphics, Upload, Download do not work in backgrnd
#65050 Data types and file formats in files (DATASET)
#145073 - FAQ Report Writer: Excel download
#569537 - Incorrect data during import into Excel
#590126 Sending CSV documents up to Release 4.6
Please be aware that they are all Basis notes. So for more information you might ask in the Basis SDN Forum.
Best regards, Christin Angus -
How to Download ALV Output LOGO to Excel ?
Hi
I have Used the LOGO in ALV Output. Iam getting the LOGO through REUSE_ALV_GRID_DISPLAY. If i download the Data to Excel file, the LOGO is not coming. How to solve this problem.
Thanks & Regards,
N.L.Hi,
I had a sample code wich will insert LOGO from PRESENTATION server into excel / word.
TYPE-POOLS ole2.
DATA:
o_word TYPE ole2_object,
excel TYPE ole2_object,
o_documents TYPE ole2_object,
o_actdoc TYPE ole2_object,
o_inlineshapes TYPE ole2_object,
o_logo TYPE ole2_object,
WORKBOOK TYPE ole2_object.
*CREATE OBJECT o_word 'Word.Application'.
CREATE OBJECT EXCEL 'Excel.Application'.
*FREE OBJECT EXCEL.
*SET PROPERTY OF o_word 'Visible' = '1'.
SET PROPERTY OF excel 'Visible' = '1'.
*GET PROPERTY OF o_word 'Documents' = o_documents.
GET PROPERTY OF excel 'Documents' = o_documents.
CALL METHOD OF o_documents 'Add' = o_actdoc.
CALL METHOD OF EXCEL 'WORKBOOKS' = WORKBOOK.
GET PROPERTY OF o_actdoc 'InlineShapes' = o_inlineshapes.
CALL METHOD OF o_inlineshapes 'AddPicture' = o_logo
EXPORTING
#1 = 'C:\Temp\OTHERS\Scrap\COMPANY_LOGO.BMP'
#2 = 0
#3 = 1.
WRITE: / 'Test'.
Let us see if some one will come out with good idea/Example.
Thanks. -
Download ALV output to excel with formatting
Hi All,
i want to download ALV output to excel sheet and the uneditable fields in ALV oputput should be locked (uneditable) in excel also.
Can you please tell me approach to achieve this functionality?
Thanks in advance.Thanks Vamsi. Your Suggestion was helpful.
I have used excel integration and used SET PROPERTY OF (COLUMN) 'LOCKED' = 1.
For more details refer below mentioned link.
http://webcache.googleusercontent.com/search?q=cache:SoY6hFC17PoJ:wiki.sdn.sap.com/wiki/display/Snippets/Download%2BData%2Binto%2BMultiple%2BSheet%2BExcel%2BDocument%2Bwith%2BNon%2BEditable%2BColumns%2B(Password%2Bprotected)%2BUsing%2BABAP%2BOLESetPropertynoteditableexcelsapABAP&cd=1&hl=en&ct=clnk&gl=in&source=www.google.co.in (http://webcache.googleusercontent.com/search?q=cache:SoY6hFC17PoJ:wiki.sdn.sap.com/wiki/display/Snippets/Download%2BData%2Binto%2BMultiple%2BSheet%2BExcel%2BDocument%2Bwith%2BNon%2BEditable%2BColumns%2B%28Password%2Bprotected%29%2BUsing%2BABAP%2BOLESetPropertynoteditableexcelsapABAP&cd=1&hl=en&ct=clnk&gl=in&source=www.google.co.in -
Problem in downloading ALV output in excel
Dear Abapers,
I am facing a problem while downloading alv output in spreadsheet. Report headers and data headings are coming in excle but contents are missing instead of that No Data is displaying on excel sheet. I have debug that and observed the deep structure name T_OUTTAB using by the FM ALV_DATA_EXPORT is empty, It should contain the contents of my output data.
Below I am giving my code.
***********************************************declaration****************
BEGIN OF d_file_out,
index TYPE i, "Index no
msg TYPE string, "Message
msgtyp(1) TYPE c, "Message type
END OF d_file_out,
DATA:t_file_out TYPE TABLE OF d_file_out.
DATA:wa_file_out TYPE d_file_out.
Display Error Logs
PERFORM display_logs USING text-006.
FORM display_logs USING p_text TYPE string.
CONSTANTS: c_count TYPE char5 VALUE 'INDEX',
c_mestyp TYPE char6 VALUE 'MSG',
c_message TYPE char7 VALUE 'MSGTYP'.
*Field catalog
PERFORM: z_field_catalog USING c_count text-010, "Record number
z_field_catalog USING c_mestyp text-011, "Message type
z_field_catalog USING c_message text-012. "Message
*Top of page event
PERFORM z_event USING t_events.
wa_layout-colwidth_optimize = c_x.
ALV grid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_buffer_active = 'X'
i_callback_program = sy-repid
is_layout = wa_layout
I_STRUCTURE_NAME = wa_file_out
it_fieldcat = t_field
it_events = t_events
TABLES
t_outtab = t_file_out
EXCEPTIONS
program_error = 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.
***********************************Fieldcatalog**********************************************
FORM z_field_catalog USING p_field TYPE any
p_name TYPE any.
wa_field-fieldname = p_field.
wa_field-seltext_l = p_name.
IF p_field = 'INDEX'.
wa_field-outputlen = '14'.
wa_field-col_pos = 1.
ELSEIF p_field = 'MSG'.
wa_field-outputlen = '120'.
wa_field-col_pos = 2.
ELSEIF p_field = 'MSGTYP'.
wa_field-outputlen = '08'.
wa_field-col_pos = 3.
ENDIF.
APPEND wa_field TO t_field.
CLEAR wa_field.
ENDFORM.
Here I have given my code, which contain the building of field catalog and Calling ALV Grid. I have already checked the excel micros settings. Other programs are working fine on my system and downloading in excel is also working.
Hope to get reply soon.
Regards,
HimanshuHi ,
use this to down load to xcel
v_file = lv_file.
DATA: BEGIN OF s_head OCCURS 0,
head(40) TYPE c ,
END OF s_head.
s_head-head = text-015."'Sales price'. * for header
APPEND s_head.
s_head-head = text-016."'Purchase price'. * for header
APPEND s_head.
s_head-head = text-017."'Listing Procedure'. * for header
APPEND s_head.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = v_file
filetype = 'ASC'
write_field_separator = '#'
TABLES
data_tab = it_output1[]
fieldnames = s_head[]
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. -
Download specific output fields to excel
Hi All,
We have a report program that downloads an excel file having about 60 output fields. The program has no ALV output.
Everytime we do not require these 60 fields to be shown in output excel. we need specific output fields in excel and those specific fields could be dynamic.
Is there any way to download specific output fields in excel as we do in ALV variant.
In alv, we can achieve this through a layout variant in selection screen and download the alv output in excel. But we dont require alv to download excel from there.
Thanks,
Srilakshmi.Hi
Something like this:
DATA: BEGIN OF t_layout OCCURS 0,
mark TYPE c,
fieldname LIKE dd03l-fieldname,
END OF t_layout.
TYPE-POOLS slis.
DATA: gt_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.
DATA: lt_report TYPE sy-repid.
DO 60 TIMES.
t_layout-fieldname = 'Field'.
MOVE sy-index TO t_layout-fieldname+6.
APPEND t_layout.
ENDDO.
lt_report = sy-repid.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = lt_report
i_internal_tabname = 'T_LAYOUT'
i_inclname = lt_report
CHANGING
ct_fieldcat = gt_fieldcat[].
CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
EXPORTING
i_title = 'Field List'
i_zebra = 'X'
i_checkbox_fieldname = 'MARK'
i_tabname = 'T_LAYOUT'
it_fieldcat = gt_fieldcat[]
TABLES
t_outtab = t_layout.
LOOP AT t_layout WHERE mark = 'X'.
WRITE: / t_layout-fieldname.
ENDLOOP.
Max -
Save ALV grid to local excel-file in background
Hi,
i want to save a alv grid to an excel-file on a local fileshare using an background job..
Does anybody know how this works?
Thanks aheadDATA: file TYPE string VALUE `flights.dat`,
wa TYPE spfli.
FIELD-SYMBOLS TYPE x.
OPEN DATASET file FOR OUTPUT IN BINARY MODE.
SELECT *
FROM spfli
INTO wa.
ASSIGN wa TO CASTING.
TRANSFER TO file.
ENDSELECT.
CLOSE DATASET file.
<b>The binary data from database table SPFLI is transferred to a binary file flights.dat</b> -
Downloading Report output to a Local File
Hi,
I want to download the my ALV Report output to a local file.
I am following the menu options from ALV output:
LIST --> Export --> Local File --> Unconverted Format --> I entered a text file name on the desktop.
The data is being downloaded to Local text file, but some columns are missing.
I don't know what is the reason? Can anybody tell what may be the reason?
Has anybody come across this issue earlier?
Please let me know the solution.
Thanks in advance,
Sreenivas Reddy.Hi vik,
I have followed the same steps
LIST --> Export --> Local File --> Here I enter test.xls file on the desktop.
I am missing the same columns, The heading are displayed for all fields, but data for some initial columns are missing.
Can you please through some light on this error.
Thanks,
Sreeni. -
Procedure/sample code to download alv output in HTM format & mail to user.
Hello Experts,
I've a requirement to run the Alv report at background. But i need to download the alv output in HTM fomat because it has subtotal values & look wise downloaded HTM format will be same as that of ALV output. Then send the attachment through mail to users. I'm not intersted in downloading internal table dierctly to HTM format.
Will the code for alv display & downloading in HTM format & forwarding via email is all done in one single program or in 2 differnt programs . pls guide me on this.
I'm using FM REUSE_ALV_GRID_DISPLAY to display output with subtotals.
Pls anyone there suggest me the steps to download ALV output in HTM format & the forward the same to user ID through Lotus notes.
Regards
Devika.SHi,
This can be achieved without coding .
Fore ground Scenario:
1. Downloading as HTM . In foreground you can do this by using Export---> Local file
option in ALV grid.
Background Scenario:
2. In background while sending mail , You have to achieve the same through customisation settings as wexplained below.
In SM36 -- > Spool List Recipient, give the reciepient id and click on copy. Now when the Background job will be finished,
the reciepient mentioned above will recieve the mail , but in ALI format.
To convert the same to HTM format, you need to do customisation changes in SCOT
goto SCOT>Expant the node INT>Double click on Email-->Beside Internet we have SET tab , click on that -->
select the radio button " all formats except the following ">In the near by box type ALI>then click on the tick Mark.
Then go to SCOT>Settings>Conversion Rules-->there
create a new row with, Format->ALI , To Format->HTM , Ranking 1, FM -> SX_OBJECT_CONVERT_ALI_HTM.
Now when the mail will be sent, it will not go in ALI, but in HTM format.
Hope this helps you out. -
Reg. ALV output transported into Excel
Dear All,
when i transported my ALV report output to excel file , amount column is suppressed from decimal places .
i.e. in excel file , decimal values of amount column is not shown in some amounts.
Please provide some inputs
Thanks & Regards
shaileshHi ,
Check this [LINK|ALV List output to Excel file; for ALV output transported into Excel.
hope it will help you .
Regards,
Saravana.S -
How to send ALV output data into Excel sheet format via Mail to the user?
Hi friends,
I have a doubt ie,
How to send ALV output data into Excel sheet format via Mail to the user?
regards
MoosaHi,
Provide the output internal table to the objbin in the below FM
Send Message
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = i_docdata
put_in_outbox = c_x
TABLES
packing_list = i_objpack
object_header = i_objhead
contents_bin = i_objbin
contents_txt = i_objtxt
receivers = i_reclist
and specify the document type
i_objpack-doc_type = 'XLS'.
and try.
Regards,
Nandha -
How to download data from spool to excel file
Hi,
I have requirement like....i need to download data from spool to excel file.
Please let me know the process how to download...
<removed by moderator>
<removed by moderator>
Thanks,
Khasimsa
Moderator message: please (re)search yourself before asking, do not assign priorities, do not offer re-ward
locked by: Thomas Zloch on Sep 8, 2010 1:18 PMHi try this way..
*FM called that returns the Spool Request Number data into and internal table
CALL FUNCTION 'RSPO_RETURN_ABAP_SPOOLJOB'
EXPORTING
rqident = p_spool "Spool Request Number
first_line = 1
TABLES
buffer = it_spool_xls "Internal table that will have the Spool Request No data
EXCEPTIONS
no_such_job = 1
not_abap_list = 2
job_contains_no_data = 3
selection_empty = 4
no_permission = 5
can_not_access = 6
read_error = 7
OTHERS = 8.
*To convert the spool data into excel format
CALL FUNCTION 'SO_RAW_TO_RTF'
TABLES
objcont_old = it_spool_xls "Internal table having spool data
objcont_new = it_xls_spool. "Int table having Excel format data converted from Spool data
"call GUI down Load by passing it_xls_spool
Prabhudas -
Problem while downloading Chinese chatracters into an excel file
Hi All ,
While downloading Chinese characters into an excel file , using GUI_DOWNLOAD function module , im getting JUNK Characters instead of chinese characters.
But if im downloading the same chinese data into an text file or unix file , there is no such problem.
Thanks in advance and points will be rewarded for helpful answer.
Regards,
K.S.RHi, I have the same problem. Anyone has solution now?
Wu Hao
2008/08/21 -
Query output transfer to excel file
hi all,
how can i query output transfer to excel file ? i am not using any tool. please suggest me. is there any method that i transfer that output to excel file?You can create a csv file. See dump_csv function from Tom Kyte.
Maybe you are looking for
-
Installation was interrupted message for a routine upgrade
Right after "Publishing product information": "The iTunes for Windows installer has completed. The installation was interrupted before iTunes could be completely installed. The System has not been modified. To install this program at a later time, ru
-
Is it normal for someone to have general diffuculty charging an ipad? I see the "not charging" message even when I am using the charger and cord that came in the original box, plugged into a wall socket directly. It is normal for me to plug it in o
-
The same songs appearing Multiple (3-4) times in iTunes
It seems like nearly every song in my iTunes is in there 3 to 4 times. Is there anyway to get rid of this besides manually going through and deleting each one? I have tried consolidating my library using the iTunes feature, and I have disabled the sh
-
How to get quicktime movie into FCP X?
how to get quicktime movie into FCP X?
-
Has anyone seen this error and knows what to do to fix it? The Microsoft Operations Manager Scheduler Data Source Module failed to initialize because some window has no day of the week set. One or more workflows were affected by this. Workflow name: