cancel
Showing results for 
Search instead for 
Did you mean: 

Make custom button invisible/HIDE in alv webdynpro

mahesh_jagnani
Participant
0 Kudos

Hello Expert,

i created one custom button in alv by program:-

**********************************

*     Create button for select all

**********************************

        try.

            l_o_function = l_o_config_scope->if_salv_wd_function_settings~create_function( /glb/cl_8gtpt_const_vend_aud=>cc_icon_select ).

          catch cx_sy_conversion_overflow

                cx_sy_move_cast_error.

            l_v_error = abap_true.

        endtry.

        try.

            create object l_o_button.

          catch cx_sy_create_object_error.

            l_v_error = abap_true.

        endtry.

        if l_v_error is initial and l_o_button is bound and l_o_function is bound.

          l_o_button->set_image_source( /glb/cl_8gtpt_const_vend_aud=>cc_icon_select ).

          l_o_function->set_editor( l_o_button ).

        endif.

Now i want to make this button invisible/hide depending on some condition.it means for some condition it will display and for some it will not.

Please suggest how to acheive this.

Thanks

Mahesh

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You can make use of SET_VISIBLE( ) method of cl_salv_wd_function class. Here i've created one ALV button and based on authorization, i'm enabling/disabling the same button. PFB the sample code.


DATA lr_buttonui        TYPE REF TO cl_salv_wd_fe_button.
DATA button1            TYPE REF TO cl_salv_wd_function.

*----->Button1
      CREATE OBJECT lr_buttonui.
      lr_buttonui->set_text( 'Test' ).
      lr_buttonui->set_tooltip( 'Test').
      button1 = lv_value->if_salv_wd_function_settings~create_function( id = '<Button Function>'')."creating the function for alv button
      button1->set_editor( lr_buttonui ).

AUTHORITY-CHECK OBJECT 'ACTVT' ID 'ACTVT' FIELD '03'. "03 = display

IF SY-SUBRC IS INITIAL.

button1->set_visibility( value = CL_WD_UIELEMENT=>E_VISIBLE-VISIBLE ).

ELSE.

button1->set_visibility( value = CL_WD_UIELEMENT=>E_VISIBLE-NONE ).

ENDIF.

And according your code,


l_o_function->set_editor( l_o_button ).

l_o_function->set_visiblevalue = CL_WD_UIELEMENT=>E_VISIBLE-VISIBLE  ).

Hope this helps you.

Thanks

KH

mahesh_jagnani
Participant
0 Kudos

Thanks alot KH,

Can you please tell me if i craeted a drop down and want to make it display only based on some condition,how i can do it?

          CALL METHOD l_o_config_scope->if_salv_wd_column_settings~get_column

            EXPORTING

              id    = /glb/cl_8gtpt_const_vend_aud=>cc_status

            RECEIVING

              value = l_o_column.



          TRY.

              CREATE OBJECT l_o_dropdown

                EXPORTING

                  selected_key_fieldname = /glb/cl_8gtpt_const_vend_aud=>cc_status.

            CATCH cx_sy_create_object_error.

              l_v_error = abap_true.

          ENDTRY.



          IF l_v_error IS INITIAL AND l_o_column IS BOUND AND l_o_dropdown IS BOUND.

*     Assigning input field to the column

            CALL METHOD l_o_column->set_cell_editor( l_o_dropdown ).

          ENDIF.

i donot want drop down in some condition and that means display only.

Thanks

Mahesh

Former Member
0 Kudos

Hi,

Check the below code. Here based on authorization, i'm making dropdown field readonly.


AUTHORITY-CHECK OBJECT 'ACTVT' ID 'ACTVT' FIELD '03'. "03 = display 

IF SY-SUBRC IS INITIAL. 
l_o_dropdown->set_read_only( value = ABAP_FALSE ).
ELSE. 
l_o_dropdown->set_read_only( value = ABAP_TRUE ).
ENDIF. 

Hope this helps you.

Thanks

KH

Former Member
0 Kudos

Hi,

Pls close the thread if your issue is resolved else revert with your query's.

Thanks

KH

Answers (0)