cancel
Showing results for 
Search instead for 
Did you mean: 

how to hide ALV Button row wise?

Former Member
0 Kudos

Hi,

I have created dynamic ALV in web dynpro and added button on column . But I need to hide the button row wise.

Now all rows showing the button. But I need to show only for fews rows with respect to value on this column.

Could you please help me regarding this point.

Thanks and regards

Amita Gandhi

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I try both solution but I am not getting any solution

1) With this solution I can display the Button on Condition basis but for other cells( which does not contain the Button) value is not showing. it is howing blank value. I want value over there?

loop at el_elements into el_element.

el_element->get_attribute( exporting name = 'CARRID'

importing value = lwa_sflight-CARRID ).

clear lwa_sflight-BUTTON_VIS.

if lwa_sflight-CARRID = 'LH'.

lwa_sflight-BUTTON_VIS = '02'."cl_wd_table_column=>e_cell_design.

endif.

append lwa_SFLIGHT to t_SFLIGHT.

endloop.

lr_button->SET_VISIBLE_FIELDNAME( 'BUTTON_VIS' ).

2) If I try with another method with SET_SEL_CELL_VARIANT_FIELDNAME

It is showing run time error :The following error text was processed in the system EID : Adapter error in &VIEW_ELEMENT_TYPE& "CARRID" of view "SALV_WD_TABLE.VIEW_TABLE": CellVariant ID "TEXT_VIEW" does not exist

Nd_ALV_Sflight = wd_context->get_child_node('ND_ALV_SFLIGHT').

nd_Sflight->get_static_attributes_table( IMPORTING table = t_SFLIGHT ).

loop at t_SFLIGHT into lwa_sflight.

if lwa_sflight-CARRID = 'LH'.

lwa_sflight-text = 'BUTTON'.

else.

lwa_sflight-text = 'TEXT_VIEW'.

endif.

modify t_SFLIGHT from lwa_sflight.

endloop.

lr_column->SET_SEL_CELL_VARIANT_FIELDNAME( 'TEXT' ).

Former Member
0 Kudos

Hi,

when you try the first option, when you delete the button on condition, then it is a text view by default, but you need to fill the value by urself here. otherwise that cell value will be missed out.

For 2nd option,

Check the binding and mapping is correctly done. You will get the results using 2nd also.

Please remove the EXTERNAL BINDING for ALV DATA node and do the mapping again.

Check out this link for cell variant -

https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f0e7461d-5e6c-2b10-dda9-9e99df4d...

Regards,

Lekha.

Former Member
0 Kudos

Hi Lekha,

thanks for the help.

I got the answered with the second method.

Thanks and regards

Amita Gandhi

Former Member
0 Kudos

HI,

I have a ALV table in that buttons Print,Check,Apppend Row,Delete Row,Insert Row buttons are there.But client requirement is they don't want those buttons in ALV they want in above the ALV table.

Can you please let me know how to hide those buttons in ALV.and give me code Print,Check,Apppend Row,Delete Row,Insert Row action code..

Answers (2)

Answers (2)

Former Member
0 Kudos

1) how to fill value again . Value is already there in the Column. Only it is invisible.

My code :

refresh t_SFLIGHT.

nd_Sflight = wd_context->get_child_node('ND_SFLIGHT').

el_elements = nd_Sflight->get_elements( ).

Nd_ALV_Sflight = wd_context->get_child_node('ND_ALV_SFLIGHT').

nd_Sflight->get_static_attributes_table( IMPORTING table = t_SFLIGHT ).

loop at t_SFLIGHT into lwa_sflight.

if lwa_sflight-CARRID = 'AZ'.

lwa_sflight-BUTTON_VIS = '02'.

endif.

modify t_SFLIGHT from lwa_sflight.

endloop.

CALL METHOD Nd_ALV_Sflight->BIND_TABLE

EXPORTING

NEW_ITEMS = t_SFLIGHT

SET_INITIAL_ELEMENTS = ABAP_TRUE

  • INDEX =

.

CREATE OBJECT lr_button.

lr_button->set_text_fieldname( 'CARRID' ).

lr_button->SET_VISIBLE_FIELDNAME( 'BUTTON_VIS' ).

lr_column->set_cell_editor( lr_button ).

2) For the second option Please check my code and let me know if any problem?

now it is showing following error

"The following error text was processed in the system EID : Adapter error in &VIEW_ELEMENT_TYPE& "MANDT" of view "SALV_WD_TABLE.VIEW_TABLE": CellVariant ID "BUTTON" does not exist "

please check my code for 2nd option

refresh t_SFLIGHT.

nd_Sflight = wd_context->get_child_node('ND_SFLIGHT').

el_elements = nd_Sflight->get_elements( ).

Nd_ALV_Sflight = wd_context->get_child_node('ND_ALV_SFLIGHT').

nd_Sflight->get_static_attributes_table( IMPORTING table = t_SFLIGHT ).

loop at t_SFLIGHT into lwa_sflight.

if lwa_sflight-CARRID = 'AZ'.

lwa_sflight-text = 'BUTTON'.

else.

lwa_sflight-text = 'TEXT_VIEW'.

endif.

modify t_SFLIGHT from lwa_sflight.

endloop.

CALL METHOD Nd_ALV_Sflight->BIND_TABLE

EXPORTING

NEW_ITEMS = t_SFLIGHT

SET_INITIAL_ELEMENTS = ABAP_TRUE

  • INDEX =

.

  • Display button in column carrid

data: lr_column type ref to cl_salv_wd_column.

data: l_value type ref to cl_salv_wd_config_table.

DATA: lr_button TYPE REF TO cl_salv_wd_uie_button,

lr_textview TYPE REF TO cl_salv_wd_uie_text_view.

l_value = l_intf_controller->get_model( ).

lr_column = l_value->if_salv_wd_column_settings~get_column( 'CARRID' ).

t_columns = l_value->if_salv_wd_column_settings~get_columns( ).

LOOP AT t_columns INTO lwa_column.

CREATE OBJECT l_cell_var.

l_cell_var->set_key( 'TEXT_VIEW' ).

CREATE OBJECT l_textview.

l_textview->set_text_fieldname( lwa_column-id ).

l_cell_var->set_editor( l_textview ).

lwa_column-r_column->add_cell_variant( r_cell_variant = l_cell_var ).

lwa_column-r_column->set_sel_cell_variant_fieldname( 'TEXT' ).

CASE lwa_column-id.

WHEN 'CARRID'.

CREATE OBJECT l_button .

  • EXPORTING checked_fieldname = lwa_column-id.

lwa_column-r_column->set_cell_editor( l_button ).

ENDCASE.

ENDLOOP.

lr_column->SET_SEL_CELL_VARIANT_FIELDNAME( 'TEXT' ).

Edited by: AmitaGandhi on Jul 15, 2009 3:37 PM

Edited by: AmitaGandhi on Jul 15, 2009 3:38 PM

Former Member
0 Kudos

Hi Amita,

This is very simple.Just take one additional attribute say a_disable of type wdy_boolean and then populate the variable with value abap_true where ever you want to enable the button else abap_false where you want to disable the button.

Call this method after you create the button

CALL METHOD SET_VISIBLE_FIELDNAME

EXPORTING

VALUE = 'A_DISABLE'.

Follow the below article where I am making some of the cells editable and some are non editable.

https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f0625002-596c-2b10-46af-91cb31b7...

Former Member
0 Kudos

I have added dynamic ALV and Node is using for the data . so it will not helpful. Could you provide me how to delete Cell button

Please refer my code

data: l_cmp_api type ref to if_wd_component,

l_cmp_usage type ref to if_wd_component_usage,

l_api type ref to if_wd_view_controller,

l_intf_controller type ref to iwci_salv_wd_table,

l_node type ref to if_wd_context_node.

l_cmp_api = wd_comp_controller->wd_get_api( ).

l_api = wd_this->wd_get_api( ).

if wd_this->cmp_usage_group is initial.

wd_this->cmp_usage_group = l_cmp_api->create_cmp_usage_group(

name = 'ALV_USAGE_GROUP'

used_component = 'SALV_WD_TABLE' ).

l_cmp_usage = wd_this->cmp_usage_group->add_component_usage(

name = 'ALV_USAGE'

used_component = 'SALV_WD_TABLE').

l_cmp_usage->create_component( ).

l_api->do_dynamic_navigation(

source_window_name = 'ZTABA_19_GAN_SFLIGHT'

source_vusage_name = 'MAIN_USAGE_0'

source_plug_name = 'TO_ALV'

target_component_name = 'SALV_WD_TABLE'

target_component_usage = 'ALV_USAGE'

target_view_name = 'TABLE'

target_plug_name = 'DEFAULT'

target_embedding_position = 'MAIN/VIEWCON1' ).

l_node = wd_context->get_child_node( 'ND_SFLIGHT' ).

l_intf_controller ?= l_cmp_usage->get_interface_controller( ).

l_intf_controller->set_data( l_node ).

  • Display button in column carrid

data: lr_column type ref to cl_salv_wd_column.

data: l_value type ref to cl_salv_wd_config_table.

DATA: lr_button TYPE REF TO cl_salv_wd_uie_button.

l_value = l_intf_controller->get_model( ).

lr_column = l_value->if_salv_wd_column_settings~get_column( 'CARRID' ).

CREATE OBJECT lr_button.

lr_button->set_text_fieldname( 'CARRID' ).

lr_column->set_cell_editor( lr_button ).

Former Member
0 Kudos

Hi,

One thing you do.

When you delete button you need to replace it either TEXT_VIEW or any UI element right.

Based on the yuor condition create a button and Textview using CELL_VARIANT attribute.

As Suman suggested, You can use a context attribute for CELL_VARIANT type string.

Based on the condition, populate the value of cell_vairant as BUTTON or TEXT_VIEW.

Now, when you get the column references,

SET_SEL_CELL_VARIANT_FIELDNAME( 'CELL_VARIANT' ).

Or

As per Suman's comments also, once you get the reference of the button you need to set the Visible property.

  • Display button in column carrid
    data: lr_column type ref to cl_salv_wd_column.
    data: l_value type ref to cl_salv_wd_config_table.
    DATA: lr_button TYPE REF TO cl_salv_wd_uie_button.
    l_value = l_intf_controller->get_model( ).
    lr_column = l_value->if_salv_wd_column_settings~get_column( 'CARRID' ).
    CREATE OBJECT lr_button.
    lr_button->set_text_fieldname( 'CARRID' ).
    lr_button->set_visible_field_name
    exporting
    value = 'VISIBLE'           --------------------------->Here you have to include that code
    lr_column->set_cell_editor( lr_button ).

Regards,

Lekha.