cancel
Showing results for 
Search instead for 
Did you mean: 

How can i add a menu item to the standard button 'Export'

0 Kudos

Hi All,

I have a requirement, For an ALV data export i need to provide two options for the customer.

one is 'Export to Excel' and another is 'Export to CSV'. As we know Export to Excel is a standard functionality provided as menu button, i have created another button to perform Export to CSV and it works well. But customer doesnt want this as a separate button and asking to add this as another menu item to the standard button 'Export' .

How can i achieve this?

Thanks,

Ramakrishna

Accepted Solutions (1)

Accepted Solutions (1)

former_member184578
Active Contributor
0 Kudos

Hi,

You can achieve this using button choice UI.

DATA: lr_func_settings       TYPE REF TO if_salv_wd_function_settings,
        lr_function            TYPE REF TO cl_salv_wd_function,
        lr_menu_action         TYPE REF TO cl_salv_wd_menu_action_item,
        lr_button_choice       TYPE REF TO cl_salv_wd_fe_button_choice,

* create button choice
  CREATE OBJECT lr_button_choice.
* create new tool bar button choice
  lr_function = lr_func_settings->create_function( 'BUTTON_CHOICE_TB' ).
  lv_text = 'Demo Btn Choice'
  lr_button_choice->set_text( lv_text ).


* create menu objects for button choice
    lv_id = 'EXP_EXCEL'
    lv_text = 'Export to Excel'.
    CREATE OBJECT lr_menu_action
      EXPORTING
        id = lv_id.
    lr_menu_action->set_text( lv_text ).
*   Add action menu to button choice
    lr_button_choice->add_choice( lr_menu_action ).

* 2nd item

   lv_id2 = 'EXP_CSV'

    lv_text = 'Export to CSV'.

    CREATE OBJECT lr_menu_action

      EXPORTING

        id = lv_id.

    lr_menu_action->set_text( lv_text ).

    lr_button_choice->add_choice( lr_menu_action ).


  lr_function->set_editor( lr_button_choice ).

You can also get the existing Function and use add_choice to add another Item



lr_function = lr_functions->get_function_std( 'FUNC_ID' ). " func_id is the ID of standard function

You can also refer this document for adding custom button in Toolbar

Hope this helps u,

Regards,

Kiran

0 Kudos

Thanks Kiran.

Mareidem
Explorer
0 Kudos

Hello Kiran,

I try with your code, but my webdynpro doesn't work.I don't know what I forget.

Must I create a particolar context node? If yes, how can link it with my choice-button?

Thanks,

Marino

former_member184578
Active Contributor
0 Kudos

Hi,

Could you please be more specific! Looks like you are mentioning about your open query which was replied here:

Regards,

Kiran

Faaiez
Advisor
Advisor
0 Kudos

I am trying to do exactly as described in this post by adding items to the Export button and not creating a new button choice as described.

The hint states:

    


lr_function = lr_functions->get_function_std( 'FUNC_ID' ). " func_id is the ID of standard function

Alhtough I do get the standard function using 

     lr_function_std = lr_func_settings->get_function_std( if_salv_wd_c_std_functions=>export ).

I cannot see how to assign it to a reference that I can use to add the action items to.

Answers (0)