cancel
Showing results for 
Search instead for 
Did you mean: 

To hide a button in a column field depending on the condition in ALV

Madhu2004
Active Contributor
0 Kudos

Hai,

I have a column in ALV with buttons.I need to make that button Visible or invisible based on a condition.

i have fiels with value x and blank.

if the value is x i need to make the button visible and viceversa.

Cheers,

Madhu.

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi,

I assume when you say that you have a field with value X or blank that you have a internal table with one of the field as mentioned above and also a context node with

the same structure of the internal table so that you bind the internal table to the node

and display the same in ALV.

If my assumptions are right you must proceed as follows.

1.Create an internal table with the same structure that u had passed for ALV.Add one more column to that table with type wdui_visibility.

2.Create one more node with the structure of the internal table created above.

3.Move the coresssponding data from your old internal table to the new internal table.

4.For the new column of type wdui_visibility fill values by comparing the field with value X or blank.ie. IF value = X wdui_visibility_column-value = '02' .

IF value = blank wdui_visibility_column-value = '01' .

5.Save the changes in the new internal table.

6.Bind the new internal table to the new node.

7.Use the new node to display data in ALV.

8.Create an attribute "alv_table" of type "CL_SALV_WD_CONFIG_TABLE" in the view.

9.In the wd_init method add the following codes.


* create an instance of ALV component
  DATA:
    lr_salv_wd_table_usage TYPE REF TO if_wd_component_usage.
* get ALV component
  DATA:
    lr_salv_wd_table TYPE REF TO iwci_salv_wd_table.
* set cell editor for input fields (~make colum Wt editable)
  DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings,
        lr_column type ref to CL_SALV_WD_COLUMN,
        lr_column_hdr type ref to CL_SALV_WD_COLUMN_HEADER,
        lr_button_1 TYPE REF TO cl_salv_wd_uie_button.

  lr_salv_wd_table_usage = wd_this->wd_cpuse_<Alv component usage name>( ).
  IF lr_salv_wd_table_usage->has_active_component( ) IS INITIAL.
    lr_salv_wd_table_usage->create_component( ).
  ENDIF.

  lr_salv_wd_table = wd_this->wd_cpifc_<Alv component usage name>( ).
  wd_this->alv_table = lr_salv_wd_table->get_model( ).

 lr_column_settings ?= wd_this->alv_table.
lr_column = lr_column_settings->get_column( '<column name which you want to show 
                  as button>' ).
CREATE OBJECT lr_button_1.
  lr_button_1->set_text( '<some releavnt text>' ).
  lr_button_1->SET_VISIBLE_FIELDNAME('<new column name of type 
                     wdui_visibility>').
  lr_column->set_cell_editor( lr_button_1).  

Hope this helps.

Thanks,

G.Jayaprakash

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Madhu.

Pls go through this thread:

Cheers,

Sascha