cancel
Showing results for 
Search instead for 
Did you mean: 

Enable/Disable a row in ALV after posting

Former Member
0 Kudos

Hi Experts,

I have a ALV table having 4 columns( last columns is Button-POST).

Initially all the rows are enabled.

When user clicks the POST it do the BAPI posting.

Que-When the Document is succesfully posted then that line must be disabled.

Let me clarify u in detail..

Suppose i have 5 row each row has delivery ,PO etc and POST button.So whichever row is selected and if its posting is successful the that row must be disables.

I have done the coding for ALV in

wd_comp_controller->alv_table_settings( ).

wd_comp_controller->alv_cell_variant( ).

wd_comp_controller->alv_cell_settings( ).

and a Separate method ON_CLICK where i am doing posting.

Everything is fine just i want to know how to disable that row. I have data of posted row in a separate table and but where i should put the logic.

Please give me in detail..

Thannks.

Accepted Solutions (1)

Accepted Solutions (1)

former_member402443
Contributor
0 Kudos

Hi Sourabh,

Here I am implementing one event handler method ON_ACTION_ENTER of event type ON_DATA_CHECK of interface controller (ALV) to handle the event u2018Enteru2019, when user changed the value and press enter in the cell. Write the code shown below to get the required output.

Method ON_ACTION_ENTER.

data:

lo_nd_flights type ref to if_wd_context_node,

lt_flights type if_main=>elements_flights,

ls_flights type if_main=>element_flights,

ls_final type if_main=>element_flights,

lt_final type if_main=>elements_flights,

ls_mod_cell type SALV_WD_S_TABLE_MOD_CELL,

lv_tabix type sy-tabix.

  • navigate from <CONTEXT> to <FLIGHTS> via lead selection

lo_nd_flights = wd_context->get_child_node( name = wd_this->wdctx_flights ).

  • Get the table data

call method lo_nd_flights->get_static_attributes_table

importing

table = lt_flights .

  • Populate READ_ONLY attribute

  • The changed cell row is editable and remaining are non editable

read table r_param->T_MODIFIED_CELLS into ls_mod_cell

with key attribute = 'PRICE'.

if sy-subrc eq 0.

loop at lt_flights into ls_flights.

lv_tabix1 = sy-tabix.

if lv_tabix = ls_mod_cell-index.

ls_flights-read_only = abap_false.

else.

ls_flights-read_only = abap_true.

endif.

modify lt_flights from ls_flights index

lv_tabix1 transporting read_only.

endloop.

endif.

  • Bind intrenal table to context node

call method lo_nd_flights->bind_table

exporting

new_items = lt_flights

  • set_initial_elements = ABAP_TRUE

  • index =

.

  • Instantiate ALV and call GET_MODEL method

data lo_cmp_usage type ref to if_wd_component_usage.

lo_cmp_usage = wd_this->wd_cpuse_alv( ).

if lo_cmp_usage->has_active_component( ) is initial.

lo_cmp_usage->create_component( ).

endif.

data lo_interfacecontroller type ref to iwci_salv_wd_table .

lo_interfacecontroller = wd_this->wd_cpifc_alv( ).

data lo_value type ref to cl_salv_wd_config_table.

lo_value = lo_interfacecontroller->get_model(

).

data:

lt_columns type SALV_WD_T_COLUMN_REF,

ls_columns type SALV_WD_S_COLUMN_REF,

lr_input type ref to CL_SALV_WD_UIE_INPUT_FIELD,

lr_text type ref to CL_SALV_WD_UIE_TEXT_VIEW,

lr_column type ref to cl_salv_wd_column,

lt_node_info type WDR_CONTEXT_ATTR_INFO_MAP,

ls_node_info type WDR_CONTEXT_ATTRIBUTE_INFO,

lv_tabix type sy-tabix,

lr_info type ref to IF_WD_CONTEXT_NODE_INFO.

types:

begin of ty_name,

name type string,

end of ty_name.

data:

lt_name type table of ty_name,

ls_name type ty_name.

lr_info = lo_nd_flights->get_node_info( ).

lt_node_info = lr_info->get_attributes( ).

loop at lt_node_info into ls_node_info.

ls_name-name = ls_node_info-name.

append ls_name to lt_name.

endloop.

call method lo_value->if_salv_wd_table_settings~set_visible_row_count

exporting

value = 50

.

  • Get all the columns references

call method lo_value->if_salv_wd_column_settings~get_columns

receiving

value = lt_columns .

  • Make the first five column editable and remaining are non editable

loop at lt_columns into ls_columns.

lr_column = ls_columns-r_column.

lv_tabix = sy-tabix.

read table lt_name into ls_name index lv_tabix.

case ls_name-name.

when 'CARRID'.

create object lr_input

exporting

value_fieldname = ls_name-name.

call method lr_column->set_cell_editor

exporting

value = lr_input .

call method lr_input->set_read_only

exporting

value = ABAP_TRUE

.

when 'CONNID'.

create object lr_input

exporting

value_fieldname = ls_name-name.

call method lr_column->set_cell_editor

exporting

value = lr_input .

call method lr_input->set_read_only

exporting

value = ABAP_TRUE

.

when 'FLDATE'.

create object lr_input

exporting

value = ABAP_TRUE

.

when 'FLDATE'.

create object lr_input

exporting

value_fieldname = ls_name-name.

call method lr_column->set_cell_editor

exporting

value = lr_input .

call method lr_input->set_read_only

exporting

value = ABAP_TRUE

.

when 'PRICE'.

create object lr_input

exporting

value_fieldname = ls_name-name.

call method lr_column->set_cell_editor

exporting

value = lr_input .

call method lr_input->set_read_only

exporting

value = ABAP_TRUE

.

when 'CURRENCY'.

create object lr_input

exporting

value_fieldname = ls_name-name.

call method lr_column->set_cell_editor

exporting

value = lr_input .

call method lr_input->set_read_only

exporting

value = ABAP_TRUE .

when 'OTHERS'.

create object lr_input

exporting

value_fieldname = ls_name-name.

call method lr_column->set_cell_editor

exporting

value = lr_input .

call method lr_input->set_read_only

exporting

value = ABAP_FALSE .

endcase.

  • To make the required row is editable

lr_input->set_read_only_fieldname( value = 'READ_ONLY' ).

endloop.

  • Set the table Editable

lo_value->if_salv_wd_table_settings~set_read_only( value = abap_false ).

  • delete column

call method lo_value->if_salv_wd_column_settings~delete_column

exporting

id = 'READ_ONLY' .

Endmethod.

Might me this help u in solving ur issue.

Regards

Manoj Kumar

Former Member
0 Kudos

solved

Answers (1)

Answers (1)

Former Member
0 Kudos
Former Member
0 Kudos

Hi Suman,

I have alreadz gone through ur link, but could not undersatnd.

I know u must have some good ideas please help me.

And one more request , i have posted a Question on Drop Down bz Index todaz.

Please help me on that. I will be thankful to u.

Former Member
0 Kudos

Hi Saurabh,

It is very simple.If you properly understand my articles ,you would have got idea.Any how I am going to explain you what you have to do.

create a context attribute in addition to your context attributes like 'READ_ONLY' type ABAP_BOOL.

now write the below logic in onaction of your button.

Get the table data.

Populate the read_only value with abap_false for corresponding row in internal table.

Now get all columns and loop them and write the below code.

call method lo_value->if_salv_wd_column_settings~get_columns

receiving

value = lt_columns .

loop at lt_columns into ls_columns.

lr_column = ls_columns-r_column.

lv_tabix = sy-tabix.

read table lt_name into ls_name index lv_tabix.

create object lr_input

exporting

value_fieldname = ls_name-name.

call method lr_column->set_cell_editor

exporting

value = lr_input .

*To make the required row is editable

lr_input->set_read_only_fieldname( value = 'READ_ONLY' ).

endloop.

*Set the table Editable

lo_value->if_salv_wd_table_settings~set_read_only( value = abap_false ).

*delete column

call method lo_value->if_salv_wd_column_settings~delete_column

exporting

id = 'READ_ONLY' .