09-18-2014 9:07 PM
Hi,
I would like to have a standard button for export to Excel in my ALV toolbar.
I can get this button using FM reuse_alv_grid_display. Now, I am using the CL_GUI_ALV_GRID approach and there is no such button. I couldn't figure out how to add it.
Please help experts
Thank you
Tomas
09-18-2014 9:17 PM
try this:
LV_UCOMM = CL_GUI_ALV_GRID=>MC_FC_VIEW_EXCEL.
CALL METHOD GR_ALVGRID->SET_FUNCTION_CODE
CHANGING
C_UCOMM = LV_UCOMM.
09-18-2014 9:23 PM
Thanks. When should I call this? Is this going to add the button?
09-18-2014 9:48 PM
use this before set table for first display, yes it will add the button
09-18-2014 10:47 PM
Ok, thanks for advice, but it doesn't work for me for some reason.
When I call it before SET_TABLE_FOR_FIRST_DISPLAY, it ends with error 0K534 saying that it lost the output table (no wonder, it will be set in set_table_for_first_display).
I also tried it AFTER the set_table_for_first_display and it didn't crash, but instead of the ALV it showed directly a blank Excel sheet...
Apparently, I'm doing something wrong...
09-19-2014 7:34 AM
Will not the method execute the function code (and why if public, SAP set a description "Internal Use Only!"
Regards,
Raymond
09-19-2014 7:39 AM
my bad, it has to be attached to usercommand, I think tehre shd be a way to attach FC to toolbar. will check
09-19-2014 7:56 AM
To add functions to the ALV toolbar, you have to handle event toolbar of cl_gui_alv_grid to add your button(s), eventually handle_menu_button if you also want some menu, then event user_command to execute the function (or call a standard method in your case)
Regards,
Raymond
09-19-2014 8:07 AM
Thank you, I will try it.
So much trouble for one standard button
10-02-2014 1:15 PM