Excel download in ALV list
Hi All,
I am displaying a list using FM, "REUSE_ALV_GRID_DISPLAY". In the list when I press the Excel icon, an excel file opens without any data in it. Do I need to take care of data download in my User command during the FM call? If yes, how do I do that?
Thanks.
Pankaj.
Hi,
Look at the following sample code...........
CALL FUNCTION <b>'REUSE_ALV_GRID_DISPLAY'</b>
EXPORTING
i_callback_program = i_repid
i_callback_user_command = 'USER_COMMAND_PERNR'
it_fieldcat = header
is_layout = gt_layout
i_callback_top_of_page = 'TOP-OF-PAGE1'
i_grid_title = text-t06
it_sort = gt_sort[]
i_default = 'X'
i_save = 'U'
is_variant = gt_variant
it_events = gt_events
TABLES
t_outtab = ITAB.
clear itab.
endif.
Form TOP-OF-PAGE1
form top-of-page1.
data: header type slis_t_listheader,
wa type slis_listheader. "infield like wa-info, nline type n.
wa1 type slis_listheader,
wa2 type slis_listheader.
TITLE AREA
wa-typ = 'S'.
wa-info = text-t04.
append wa to header.<<<----Header text
******Here you can fill it***********
wa-typ = 'S'.
wa1-typ = 'S'.
wa2-typ = 's'.
write <your field-low> to wa1-info.
write <your field-high> to wa2-info.
concatenate 'Date' wa1-info 'to' wa2-info into wa-info separated by space.
append wa to header.<<<<---Date range i think
wa-typ = 'S'.
concatenate text-t02 sy-UNAME into wa-info separated by space.
append wa to header.<<<--User name
wa-typ = 'S'.
concatenate text-t01 sy-repid into wa-info separated by space.
append wa to header.<<<<---Report name
call function 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = header
i_logo = 'ENJOYSAP_LOGO1'.<<<<---LOGO if needed
endform.
You can check the below links also......
http://www.sapdevelopment.co.uk/reporting/alvhome.htm
ALV
http://www.geocities.com/mpioud/Abap_programs.html
Cheers
ALfred
If this helps you reward with points.
Similar Messages
-
Excel download from ALV not working inproduction
Hi all,
I am using "set_table_for_first_display" for alv display. the excel download from alv is woking fine in development and quality stystem but in production only first 3-4 rows are getting downloaded. Other rows donot appear in excel.
Any Idea !!!
Thanks
MadhuHi Experts,
I have noticed that same problem is occuring in development system also with same set of data . The ascii file created has some missing rows. I guess its due to some special characters though i am not able to see any special character . Any solution for this.
Regs
madhu -
Regarding Excel Download in Block list ALV
Hi Abaper's,
I am facing with one problem during downloading of the BlockList ALV.
<b>If I click on the standart toolbar 'local file button '( ctrl + shift + F9) it is downloading the ALV data into the excel file but the ALV header information starts from column 1 and ALV data information starts from the 2nd column.</b>
Please suggest me is it the expected functionality of the Block List ALV or I have written wrong code. Please suggest me.I think there is something wrong with the output...maybe you should check your fieldcatalog wheter it matches to the structure of your internal table of data you want to show.
Normally you should get an output per column with the fieldnames in the first line starting with 1st column and the data starting in 2nd line starting with 1st col.
hope that helps you off, please award if useful!
Clemens -
Issue in Excel download from ALV output
Dear Experts,
I have generated an ALV Output using FM "REUSE_ALV_GRID_DISPLAY". When i try to download the ALV Output in Excel spreadsheet, I am not getting the data in Excel sheet. Kindly help me in this regard.
Thanks in advance,
Regards,
Ramesh Manoharanhi ramesh,
Please try below options.
after getting the ALV disply , Go to Menu LIST->Export->Spreadsheet.or microsoft excel view (Cntrl + Shift + F7)
It will give some options to see the data in spread sheet format, hope you can save this to local desktop also.
or
please check the extension, it should be .XLS not .XLSX .some times .XLSX format wont be supported
regards,
pradeep
Edited by: Pradeep Kandgal on Aug 4, 2010 6:54 PM
Edited by: Pradeep Kandgal on Aug 4, 2010 6:54 PM -
Hi Guys,
Im facing a peculiar problem.
When I try to download an ALV report in excel format using (list ->export -> local file-> soread sheet )Im not able to download complete set of records.
Same is happening with ws_download, even though the internal table contains all the record; the number of downloaded records are not same.
Any one faced same problem. Pls. help me out.
Regards,
Sumitlooks strange!!!!!!!!!!!
change these in excel sheet and check out if it works
Change the macro settngs in your excel sheet and checkout if it works
Open empty excel sheet
In menu Tools>Macros>Security , change the radiobutton to medium
And also
In the Same popup , goto the second tab Trusted Publishers and check the checkbox Trust access to visual basic Project -
Excel download from ALV grid, for characters more than 1020
Hi,
When i am trying to download the report which is having character more than 1020, it is coming in two rows. I want all fields in one row. Please give solutions.
I am using below field catalog.
Car Eligibility
CLEAR lw_fieldcat.
lw_fieldcat-fieldname = text-001.
lw_fieldcat-reptext_ddic = text-011.
lw_fieldcat-tabname = text-021
APPEND lw_fieldcat TO gt_fieldcat.
I am using below FM.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
is_layout = gt_layout
it_fieldcat = gt_fieldcat[]
it_sort = gt_sort[]
it_events = gt_events[]
TABLES
t_outtab = gt_data
EXCEPTIONS
program_error = 1
OTHERS = 2.
Thanks in Advance,
Ravi Kumarravi,
its not about how you have used your field catalog or how you called ALV FM. its excel download functionality,
what you need to do is:
set pf-status '<<some value>>' -> you can find where to pass in ALV FM call.
then add a application toolbar button though this pf status.
then at use_command event, check sy-ucomm and if its the same as your new icons fcode then use the method to download it in excel. -
Problem in excel download of ALV report
Hi All,
I have created an ALV report with 87 fields in it. Whenever I am trying to download that report into excel the number of column breaks into 2 rows. In this case, The downloaded file contains 57 Columns in 1 row and remaining 29 Columns in second row. Can anyone please help me in understanding why this is happening while downloading this report into excel file and what will be the solution to correct it.
To download the file I am using the icon placed at application toolbar or ( Cntrl + Shift + F9 ).
Waiting for your response.
Regards.
PraveshHI Parvesh,
If you want to download the ALV result to you local file however you can follow the below coding.
DATA: l_filename TYPE string,
l_filen TYPE string,
l_path TYPE string,
l_fullpath TYPE string,
l_usr_act TYPE I.
l_filename = SPACE.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
EXPORTING
DEFAULT_FILE_NAME = l_filename
CHANGING
FILENAME = l_filen
PATH = l_path
FULLPATH = l_fullpath
USER_ACTION = l_usr_act
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
NOT_SUPPORTED_BY_GUI = 3
others = 4.
IF sy-subrc = 0
AND l_usr_act <>
CL_GUI_FRONTEND_SERVICES=>ACTION_CANCEL.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = l_fullpath
FILETYPE = 'ASC'
TABLES
DATA_TAB = T_DOWNL
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. -
Trigger event of Excel download in ALV
From my menu bar on the screen can i trigger the alv
excel download feature.Hi Kaushik,
Check out the function module ALV_XXL_CALL.
Srinivas -
Excel download for ALV Block report (List- export- spreadsheet)
Dear friends,
I want to download the output into Excel...
I am using all SAP standards and using the ALV Block list
Ex: List->export->local file.. is anable from here i can download to excell .....but the same there is anothere option : List->export->spreadsheet...( this one inactive.)
I want to activate the List->export->spreadsheet option.
how to do this???
Thanks,
Sridhar.hi Sridhar,
there is already an option to download in spreadsheet format when saving to local file...then why do you want to activate List->export->spreadsheet ????
regards,
madhu -
Regarding excel download from ALV report tree
Hi Experts,
I have a ALV report tree program. In that i need the functionality to download report output in excel file.
Can any body suggest how can i achieve download to excel functionality in it.
Any useful suggestion will be appreciated.
Thanks in advance,
AkashThe data for the tree exist in the NODE table in a different format. So, even you download that table, it will not be downloaded in the TREE format. So, the user will not be able to understand the data unlike the case of a ALV GRID.
Whether it is a TREE / GRID, ultimately its the data of a internal table, that gets downloaded. But in case a TREE, we don't have the data in a straight forward way . i thnk it is not possible . i am not sure too for this . -
Excel Download of ALV with one column containing leading zeros
Hello Experts,
I have the requirement in which the first column is of type company code (T001-BUKRS). So if the company code is '0061', then on the ALV display its displayed as '0061', but when it is downloaded to Excel sheet, it shows '61' in place of '0061'.
Is there any way we can display in the downloaded Excel as 0061?
Any pointers could help.
Regards,
Mansi.Hi Mansi,
I think its because of excel property.You can format cell of excel to category 'special'.
regards
vivek -
Spreadsheet download from alv list
Dear Experts,
In my ALV Grid report, i am trying to download the report in spreedsheet by pressing (Ctrlshiftf5) and i am getting the popup window displaying "EXcel sap macros / table / pivot table" radio buttons. now i am sellecting the table radio button then i am getting the microsoft excel radio button in another popup window, after selecting this i am getting the report in spreedsheet. now my problem is some fields (currency fields, std price) are displaying the values.
can anyone give me solution for this
thanks in advance
karthikDear sathish,
I am getting values for some fields but some other fields like std price it is not displaying the values -
Excel download from ALV OOPS , columns rearranged
Hi ,
When I am downloading the data using the Export button - option Spreadsheet few of the columns are getting re-arranged. I am using OOPS ALV using Custom container.I even specified the column position in the field catalogue.
Can anyone help me to have the columns in the same order as displayed in SAP.
Many Thanks
Supriyahi,
for this problem u need to create a varient layout. here u customize the output.
while seeing the output u can use this layout.
hence your output will be similar as u seen in the system.
try and let me know...
pradeep. -
How to handle blank time value in excel download in ALV. Please help
Hi Experts,
I have a ABAP webdynpro report which contains a ALV grid output. The ALV table has a time field (create_time of type tims).
The problem is when the create_time value is initial (00:00:00 by default) it displays 00:00:00 in the ALV.
When I export the contents to excel then there it shows the same value as 12:00:00 AM.
How can I avoid this programmatically? Actually when time is initial then I want to display as blank instead of 00:00:00.
For this if I change the data type of this field to CHAR08 then it displays the value as 0 (if initial) and 140523 (if time has some value or its not initial) instead if 14:05:23.
I don't know if there is any better way to handle this.
Please help.
Thanks & Regards
GopalMy suggestion is that you make the context attribute a type string. Then when you populate the data into the internal table that is bound to the context you perform a write statement on the date field. Here is some psydo-code.
if <ls_data>-time is initial.
clear <ls_output>-time.
else.
write <ls_data>-time to <ls_output>-time.
endif.
This way when the time is inital you can display nothing instead of the 00:00:00. This should also keep Excel from knowing that this column is a time field. To Excel it will just be a string and it should display whatever text you placed into the field.
Of course this means that filtering and sorting on this field won't work right. Those operations will be befored without knowledge this is actually a time field. -
How to enable excel downloading in ALV grid report.
Hi all,
How to enable excal downing in ALV grid report?
Thanks in Advance.
Siva Sankar.hi
check the following code
Example of a Simple ALV Grid Report
REPORT ZTUFI091 .
*& Report ZDEMO_ALVGRID *
*& Example of a simple ALV Grid Report *
*& The basic requirement for this demo is to display a number of *
*& fields from the EKKO table. *
*REPORT zdemo_alvgrid .
TABLES: ekko.
type-pools: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.
*ALV data declarations
data: fieldcatalog type slis_t_fieldcat_alv with header line,
gd_tab_group type slis_t_sp_group_alv,
gd_layout type slis_layout_alv,
gd_repid like sy-repid,
gt_events type slis_t_event,
gd_prntparams type slis_print_alv.
*Start-of-selection.
START-OF-SELECTION.
perform data_retrieval.
perform build_fieldcatalog.
perform build_layout.
perform build_events.
perform build_print_params.
perform display_alv_report.
*& Form BUILD_FIELDCATALOG
Build Fieldcatalog for ALV Report
form build_fieldcatalog.
There are a number of ways to create a fieldcat.
For the purpose of this example i will build the fieldcatalog manualy
by populating the internal table fields individually and then
appending the rows. This method can be the most time consuming but can
also allow you more control of the final product.
Beware though, you need to ensure that all fields required are
populated. When using some of functionality available via ALV, such as
total. You may need to provide more information than if you were
simply displaying the result
I.e. Field type may be required in-order for
the 'TOTAL' function to work.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
fieldcatalog-do_sum = 'X'.
fieldcatalog-no_zero = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'PO Item'.
fieldcatalog-col_pos = 1.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'STATU'.
fieldcatalog-seltext_m = 'Status'.
fieldcatalog-col_pos = 2.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-seltext_m = 'Item change date'.
fieldcatalog-col_pos = 3.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material Number'.
fieldcatalog-col_pos = 4.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-seltext_m = 'PO quantity'.
fieldcatalog-col_pos = 5.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MEINS'.
fieldcatalog-seltext_m = 'Order Unit'.
fieldcatalog-col_pos = 6.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'NETPR'.
fieldcatalog-seltext_m = 'Net Price'.
fieldcatalog-col_pos = 7.
fieldcatalog-outputlen = 15.
fieldcatalog-datatype = 'CURR'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'PEINH'.
fieldcatalog-seltext_m = 'Price Unit'.
fieldcatalog-col_pos = 8.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
endform. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
Build layout for ALV grid report
form build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
gd_layout-totals_only = 'X'.
gd_layout-f2code = 'DISP'. "Sets fcode for when double
"click(press f2)
gd_layout-zebra = 'X'.
gd_layout-group_change_edit = 'X'.
gd_layout-header_text = 'helllllo'.
endform. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
Display report using ALV grid
form display_alv_report.
gd_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
i_callback_user_command = 'USER_COMMAND'
i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
it_special_groups = gd_tabgroup
it_events = gt_events
is_print = gd_prntparams
i_save = 'X'
is_variant = z_template
tables
t_outtab = it_ekko
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.
endform. " DISPLAY_ALV_REPORT
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
form data_retrieval.
select ebeln ebelp statu aedat matnr menge meins netpr peinh
up to 10 rows
from ekpo
into table it_ekko.
endform. " DATA_RETRIEVAL
Form TOP-OF-PAGE *
ALV Report Header *
Form top-of-page.
*ALV Header declarations
data: t_header type slis_t_listheader,
wa_header type slis_listheader,
t_line like wa_header-info,
ld_lines type i,
ld_linesc(10) type c.
Title
wa_header-typ = 'H'.
wa_header-info = 'EKKO Table Report'.
append wa_header to t_header.
clear wa_header.
Date
wa_header-typ = 'S'.
wa_header-key = 'Date: '.
CONCATENATE sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) INTO wa_header-info. "todays date
append wa_header to t_header.
clear: wa_header.
Total No. of Records Selected
describe table it_ekko lines ld_lines.
ld_linesc = ld_lines.
concatenate 'Total No. of Records Selected: ' ld_linesc
into t_line separated by space.
wa_header-typ = 'A'.
wa_header-info = t_line.
append wa_header to t_header.
clear: wa_header, t_line.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = t_header.
i_logo = 'Z_LOGO'.
endform.
FORM USER_COMMAND *
--> R_UCOMM *
--> RS_SELFIELD *
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
Check function code
CASE r_ucomm.
WHEN '&IC1'.
Check field clicked on within ALVgrid report
IF rs_selfield-fieldname = 'EBELN'.
Read data table, using index of row user clicked on
READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
Set parameter ID for transaction screen field
SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
Sxecute transaction ME23N, and skip initial data entry screen
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDFORM.
*& Form BUILD_EVENTS
Build events table
form build_events.
data: ls_event type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = gt_events[].
read table gt_events with key name = slis_ev_end_of_page
into ls_event.
if sy-subrc = 0.
move 'END_OF_PAGE' to ls_event-form.
append ls_event to gt_events.
endif.
read table gt_events with key name = slis_ev_end_of_list
into ls_event.
if sy-subrc = 0.
move 'END_OF_LIST' to ls_event-form.
append ls_event to gt_events.
endif.
endform. " BUILD_EVENTS
*& Form BUILD_PRINT_PARAMS
Setup print parameters
form build_print_params.
gd_prntparams-reserve_lines = '3'. "Lines reserved for footer
gd_prntparams-no_coverpage = 'X'.
endform. " BUILD_PRINT_PARAMS
*& Form END_OF_PAGE
form END_OF_PAGE.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
write: sy-uline(50).
skip.
write:/40 'Page:', sy-pagno .
endform.
*& Form END_OF_LIST
form END_OF_LIST.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
skip.
write:/40 'Page:', sy-pagno .
endform.
hope it will help you
regards
sreelatha gullapalli
Maybe you are looking for
-
Hi everyone I have just upgraded my mac pro early 2009 with an ATI 5870 and an extra 1gig of ddr3 ram. All seems to be fine no problems all the ram checks out ok and is working but this utility keeps telling me everytime I boot up or log out and into
-
Firefox has started loading external links in a new window instead of a new tab
Until recently, external links have always opened in a new tab. The last few days thaey've started opening in a new window. I can't find anything I have changed.
-
What column pertains to payment document number(AP)
Hi, what column pertains to payment document number or Payment Voucher Number as well as Related AP Voucher Number (This is the pre-defined voucher number generated by Oracle). Please include the table_name (ex test.pdn). Thanks Edited by: 796711 on
-
we have an airline pricing system whose rules change often, and rather than re-designing tables and the client application code everytime that happens, we would like to develop a rule-based system to dynamically store the rules in a rule-based system
-
Error [2] in bind() call!
hello my weblogic was working perfectly yesterday. then some genius installed some windows updates on my machine and now i get this message whenever i try to run my weblogic server: Error [2] in bind() call! err:: No such file or directory Socket tra