Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

OO ALV (cl_gui_alv_grid) - display standard Excel button

Former Member
0 Kudos

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

9 REPLIES 9

former_member205763
Active Contributor
0 Kudos

try this:

LV_UCOMM = CL_GUI_ALV_GRID=>MC_FC_VIEW_EXCEL.

      CALL METHOD GR_ALVGRID->SET_FUNCTION_CODE

        CHANGING

          C_UCOMM = LV_UCOMM.

0 Kudos

Thanks. When should I call this? Is this going to add the button?

0 Kudos

use this before set table for first display, yes it will add the button

0 Kudos

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...

0 Kudos

Will not the method execute the function code (and why if public, SAP set a description "Internal Use Only!"

Regards,

Raymond

0 Kudos

my bad, it has to be attached to usercommand, I think tehre shd be a way to attach FC to toolbar. will check

raymond_giuseppi
Active Contributor
0 Kudos

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

0 Kudos

Thank you, I will try it.

So much trouble for one standard button

0 Kudos

Yes, it worked

Thanks a lot!