Skip to Content
avatar image
Former Member

Enable/Disable a row in ALV after posting

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Feb 18, 2009 at 04:40 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 17, 2009 at 01:28 PM

    Hi Saurabh,

    Check my articles and wiki's...you will get an idea.

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

    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d0155eb5-b6ce-2b10-3195-d9704982d69b

    https://wiki.sdn.sap.com/wiki/x/QIDWAw

    Still you are not able to solve.Search in forum where I already gave answers for the same issue.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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' .