Application Development and Automation 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: 

How to add a custom button on ALV tool bar using class cl_salv_table

Former Member
0 Kudos
60,609

Hi,

Help me to add a button on the ALV tool bar using class cl_salv_table, I tried to add using add_function method but I got exception at the below statement,

gr_functions->add_function( NAME = 'display'
                             ICON = 'ICON_DETAIL'
                             TEXT = 'display'
                             TOOLTIP = 'display the list'
                             POSITION = if_salv_c_function_position=>right_of_salv_functions ).

Please help me to resolve this issue.

Thanks,

Venkat

1 ACCEPTED SOLUTION

Former Member
19,019

HI venkat,

I think you will find plenty of information in thread Edit toolbar (GUI Status) for CL_SALV_TABLE and

You can also refer the standard report  SALV_DEMO_TABLE_SELECTIONS.

Regards

Sravan

10 REPLIES 10

Former Member
19,020

HI venkat,

I think you will find plenty of information in thread Edit toolbar (GUI Status) for CL_SALV_TABLE and

You can also refer the standard report  SALV_DEMO_TABLE_SELECTIONS.

Regards

Sravan

matt
Active Contributor
0 Kudos
19,019

What exception did you get? Without that fairly basic piece of information, it's not really possible to help you.

Former Member
0 Kudos
19,019

Hi Matthew,

I got below exception

An Exception (CX_SALV_METHOD_NOT_SUPPORTED).

Thanks,

matt
Active Contributor
0 Kudos
19,019

What type is gr_functions?

Former Member
0 Kudos
19,019

This message was moderated.

Former Member
0 Kudos
19,019

Hi Venkat,

Use toolbar event of cl_gui_alv_grid class and under the implementation add the following code,

CLEAR: gd_toolbar.                    (DATA: gd_toolbar   TYPE stb_button.)

     MOVE 'BT_DISP'    TO gd_toolbar-function.

     MOVE 'Display'    TO gd_toolbar-text.

     MOVE 'Display'    TO gd_toolbar-quickinfo.

     MOVE icon_display TO gd_toolbar-icon.

     APPEND gd_toolbar TO e_object->mt_toolbar.

Regards,

Tushar

matt
Active Contributor
0 Kudos
19,019

He's using SALV; not ALV.

0 Kudos
19,019

Thanks for all,

My Problem solved.

I forgot to to set screen status.

After adding below piece of code my problem is solved.

call method gr_alv->set_screen_status

        exporting

          report   = l_report

          pfstatus = 'STANDARD'

          set_functions = gr_alv->c_functions_all.

Thanks

venkat

Arkamitra
Newcomer
0 Kudos
14,175

TRY.
CALL METHOD lo_function->add_function
EXPORTING
name = 'LOCK USER'
icon = 'ICON_LOCKED'
text = 'Lock'
tooltip = 'lOCK SELECTED USER'
position = if_salv_c_function_position=>right_of_salv_functions
.
CATCH cx_salv_existing.
CATCH cx_salv_wrong_call.
ENDTRY.                                                                                                                                    I have declared lo_function TYPE REF TO cl_salv_functions,  but getting runtime error Access using a 'ZERO' object reference is not possible.

0 Kudos
14,113

How did you fill lo_function ?

go_alv->get_functions( ).