cancel
Showing results for 
Search instead for 
Did you mean: 

inactive alv button on condition

0 Kudos

Hi Expert ,

how to set buttons on cell inactive on condition in webdynpro alv

Accepted Solutions (0)

Answers (4)

Answers (4)

0 Kudos

Hi Abhi,

I have done it , but i want to set po line item number as button text,using set_text method i am not able to do that is there any other method ?

abhimanyu_lagishetti7
Active Contributor
0 Kudos

LR_BUTTON->SET_TEXT_FIELDNAME( 'EBELN' ).

to set EBELN value as Button Text.

0 Kudos

Hi Abhi,

LOOP at gt_ekpo into gs_ekpo.

if gs_ekpo-ebelp > '20'.

CALL METHOD LR_BUTTON->SET_ENABLED_FIELDNAME

EXPORTING

VALUE = 'EBELN'

.

CALL METHOD LR_BUTTON->SET_ENABLED

EXPORTING

VALUE = ABAP_False

.

ELSEIF gs_ekpo-ebelp < '20'.

CALL METHOD LR_BUTTON->SET_ENABLED_FIELDNAME

EXPORTING

VALUE = 'EBELN'

.

CALL METHOD LR_BUTTON->SET_ENABLED

EXPORTING

VALUE = ABAP_true

.

ENDIF.

ENDLOOP.

LO_ND_EKPO->bind_table( gt_ekpo ).

this is my code it is right ?

abhimanyu_lagishetti7
Active Contributor
0 Kudos

you have to create a new attribute BUTTON_ENABLE first

SET_ENABLED_FIELDNAME should be called in WDDOINIT and only once.

This is how you fill your data.

LOOP at gt_ekpo into gs_ekpo.

if gs_ekpo-ebelp > '20'.

gs_ekpo-button_enable = abap_true. " to enable the button

ELSEIF gs_ekpo-ebelp < '.

gs_ekpo-button_enable = abap_false. " to disable the button

ENDIF.

MODIFY gt_ekpo from gs_ekpo index sy-tabix.

ENDLOOP.

LO_ND_EKPO->bind_table( gt_ekpo ).

0 Kudos

Hi Abhi,

Can you explain me more how to that .

abhimanyu_lagishetti7
Active Contributor
0 Kudos

1. create an attribute in the node which is mapped to the ALV ( BUTTON_ENABLE of TYPE WDY_BOOLEAN )

2. Code to create a button in the ALV cell

data: lr_cmp_usage type ref to if_wd_component_usage.

data: lr_intf_ctrl type ref to iwci_salv_wd_table.

data: lr_model type ref to cl_salv_wd_config_table.

data: lr_column type ref to cl_salv_wd_column.

data: lr_button type ref to cl_salv_wd_uie_button.

lr_cmp_usage = wd_this->wd_cpuse_alv( ). " ALV is component usage name

if lr_cmp_usage->has_active_component( ) is initial.

lr_cmp_usage->create_component( ).

endif.

lr_intf_ctrl = wd_this->wd_cpifc_alv( ).

lr_model = lr_intf_ctrl->get_model( ).

  • Create column for the button

lr_column = lr_model->IF_SALV_WD_COLUMN_SETTINGS~CREATE_COLUMN( 'BUTTON' ).

  • create button UI element and set as editor to the new column

CREATE OBJECT lr_button.

lr_button->set_text( 'Button Text' ).

lr_button->SET_ENABLED_FIELDNAME( 'BUTTON_ENABLE' ).

lr_column->set_cell_editor( lr_button ).

3. Your table which is mapped to the ALV have the new attribute created in step 1 BUTTON_ENABLE

Set its value to ABAP_TRUE to enable the button for that particular row

Set its value to ABAP_FALSE to disable the button for that particular row.

Abhi

abhimanyu_lagishetti7
Active Contributor
0 Kudos

Create an attribute in the node which is binded to the ALV ( BUTTON_ENABLE of type WDY_BOOLEAN )

use method SET_ENABLED_FIELDNAME of CL_SALV_WD_UIE_BUTTON to bind the attribute to the enable property of the button.

The button will be enabled or disabled based on the value in the attribute at runtime.

Abhi