Skip to Content

Strange issue on row selection in a wd_table

Hi all gurus,

I'm working on an SRM 7 system, specifically on the WD Component /SAPSRM/WDC_CTR_DOTC_IT, view V_CTR_DODC_ITEMS.

In the view there's a table showing items of a contract; we created a custom button ("item deletion") which simply triggers a method that sets the field ZZ_DEL_IND value to 'X' for the selected line(s).

Here's the method code:

METHOD onactionzdelete .

  DATA lv_action              TYPE /sapsrm/pdo_action_type.
  DATA lo_transaction_context TYPE REF TO /sapsrm/cl_transaction_context.

* Get instance of transaction object
  lo_transaction_context ?= /sapsrm/cl_transaction_context=>/sapsrm/if_transaction_context~get_instance( ).
* Set action id
  lv_action = 'DELETE_ITEM'.
  lo_transaction_context->set_current_action( iv_current_action = lv_action ).
* start ZZDEL_IND management
  DATA : lon_ctr_item     TYPE REF TO if_wd_context_node.
  DATA : lt_elem_set      TYPE wdr_context_element_set.
  DATA : ls_element       TYPE REF TO if_wd_context_element.
  DATA : deleted          TYPE abap_bool.

  CALL METHOD wd_context->get_child_node
    EXPORTING
      name       = 'CTR_ITEM'
    RECEIVING
      child_node = lon_ctr_item.

* Get the selected elements of the item table
  lt_elem_set  = lon_ctr_item->get_selected_elements( abap_true ).
* for each selected element, set ZZ_DEL_IND value
* Get the static attributes of all SELECTED elements into an internal table
  LOOP AT lt_elem_set INTO ls_element.
    CALL METHOD ls_element->set_attribute
      EXPORTING
        value = abap_true
        name  = 'ZZ_DEL_IND'.

    CALL METHOD ls_element->set_changed_by_client
      EXPORTING
        flag = abap_true.
  ENDLOOP.

  CALL METHOD wd_comp_controller->mo_bom_ctr->/sapsrm/if_cll_bo_mapper~fire_event_refresh( ).
ENDMETHOD.

Now, the problem:

- if I select a single row and press the button, ZZ_DEL_IND is set correctly for the selected row;

- if I select all the positions using the standard button SELECT->SELECT ALL , ZZ_DEL_IND is set correctly for all the selected rows;

BUT...

- if I select more than a single position (holding CTRL key down), ZZ_DEL_IND is NOT set.

In debug, I've seen that the problems are in the fire_event_refresh( ), which in case of single selection or all positions selected triggers correctly an update process, while in case of multiple selection "by hand" does not.

In details: /sapsrm/if_cll_bo_mapper~fire_event_refresh triggers a method:

me->/sapsrm/if_cll_xo_mapper~fire_event_update( )

which itself launches the update process:

me->fire_event_update( IMPORTING ev_update_performed = ev_update_performed )

Here, the method extracts all the mappers for the WD and loops over them to check for something changed:

LOOP AT lt_mapper ASSIGNING <ls_mapper>.
      CLEAR: lv_exception_occured, lv_update_performed.
      IF <ls_mapper>-mapper->is_ui_changed_by_client( ) EQ abap_true.
....

And that's the problem; when processing the mapper -> (in debug), I can see that:

- when a single row is selected, or all the rows are selected via "SELECT ALL" standard method, then the mapper results changed by client (the above condition is then satisfied)...

- while in case of multiple selection , is_ui_changed_by_client( ) = abap_false.

Has anyone suggestions on how to overcome this problem? I guess it deals with multiple selection process.

Thanks in advance

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Feb 21, 2011 at 08:06 PM

    > * Get the selected elements of the item table

    > lt_elem_set = lon_ctr_item->get_selected_elements( abap_true ).

    > * for each selected element, set ZZ_DEL_IND value

    > * Get the static attributes of all SELECTED elements into an internal table

    > LOOP AT lt_elem_set INTO ls_element.

    > CALL METHOD ls_element->set_attribute

    > EXPORTING

    > value = abap_true

    > name = 'ZZ_DEL_IND'.

    >

    > CALL METHOD ls_element->set_changed_by_client

    > EXPORTING

    > flag = abap_true.

    > ENDLOOP.

    >

    > CALL METHOD wd_comp_controller->mo_bom_ctr->/sapsrm/if_cll_bo_mapper~fire_event_refresh( ).

    > ENDMETHOD.

    I must say that this is a long post and i have difficulty to understand what exactly your problem is.

    Are you trying to say that your code

    lt_elem_set = lon_ctr_item->get_selected_elements( abap_true ).

    returns 0 elements when you select the rows with CTRL key ?

    If this is true then i would advice you to contact SAP support desk.

    Add comment
    10|10000 characters needed characters exceeded

    • >

      > Try this. i was just wondering what was the real problem and where we are heading.

      >

      Shortly: I have created a button which should set a custom field, ZZ_DEL_IND, to 'X' for all the selected rows.

      This works if the selection is a single selection or in case of a "select all" selection, but doesn't work if the selection is a multiple one done pressing CTRL + click on the rows.

      That's why I'm trying to switch from onLeadSelect to onSelect, as it manages with an event also the CTRL + click selection.

      Hope it's a bit clearer now; i'm gonna try your purposed solution and provide a feedback. In the meantime, thanks for your help.

      EDIT: I tried the purposed solution and:

      - I had a PDO layer error that closed the browser when selecting the the third row...

      - get_lead_selection() returns always the first selected row (highlighted) and not the new one selected by CTRL+click.

      I'm a bit stuck'd on the problem, I guess I'll revert to standard behaviour (using onLeadSelect instead of onSelect) and renounce to allow multiple selections via CTRL key for the task. This would be however a big limitation for the customers.

      Edited by: Matteo Montalto on Feb 23, 2011 1:52 PM

  • Mar 04, 2011 at 10:23 AM

    Hello gurus,

    I solved on my own with a workaround. Quite tricky; I'm looping over the selected position, set the current position as a lead selection by triggering the event handle_lead_position with custom parameters (built in my method) and then processing the single position. Kinda complicated, but it works 😊

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Salve Matteo,

      potresti farci una cortesia: se è possibile inviarci un esempio di codice che hai utilizzato per risolvere detto problema? Abbiamo cercato di risolverlo ma non ci siamo riusciti. Please.

      Ti ringrazio.

      Un conterraneo....