cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP WD TABLE - dynamic onSelect action binding

matteo_montalto
Contributor
0 Kudos

Hi all gurus,

I'm working on a (standard) ABAP WD Table in a Web Dynpro Component's view.

Its default selection method is set to Multi with Lead Selection; I want to switch it to MultiNoLead.


I was able to do it dynamically adding this sketch of code in WDDOMODIFYVIEW's post-exit, in "first time" condition:

* change to multiNoLead

     CALL METHOD l_table->set_selection_mode

       EXPORTING

         value = '08'. "multiNoLead

     CALL METHOD l_table->set_on_select

       EXPORTING

         value = 'ADD_TO_SELECTION'.

So, now the table selection mode is set to Multi- No Lead, and the method ONACTIONADD_TO_SELECTION is triggered any time user selects a row.



The problem is that ONACTIONADD_TO_SELECTION has the input object, WDEVENT, which is empty.

The previous, standard ONACTION_ONLEADSELECT had some useful parameters I used to:

- determine the previous lead selection;

- determine the CURRENT lead selection.

Now, on my new method, I just need to know what's the row (element) which has been selected (or deselected).

I don't know however how to define such parameters and bind them dynamically. Can anyone help me out/suggest some wiki/howto?

P.S. I can't simply use GET_SELECTED_ELEMENTS as this would return *all* the selected elements and not only the current one.

Accepted Solutions (1)

Accepted Solutions (1)

former_member215344
Contributor
0 Kudos

Hi Matteo,

You can use context change log for this purpose. Activate context log before the view is displayed. And you can get the changes by calling the method GET_CONTEXT_CHANGE_LOG() of the interface IF_WD_CONTEXT. This method will return a table with a line type WDR_CONTEXT_CHANGE

Check if there is any type 'S' record in the table (field CHANGE_KIND).

Thanks,

Ajay Bose

matteo_montalto
Contributor
0 Kudos

This sounds interesting... is there any documentation /how-to for context log?

How can I activate it?

former_member215344
Contributor
0 Kudos

Hi Matteo,

Do the following in the controller wddoinit method to activate context log:

DATA: lo_context TYPE REF TO if_wd_context.

lo_context = wd_context->get_context( ).

 

lo_context->enable_context_change_log( ).

 

 

Once the context change log is turned on, it will begin tracking changes behind the scenes. At any point along the way, we can view the contents of the change log by invoking the method

GET_CONTEXT_CHANGE_LOG() of the IF_WD_CONTEXT interface. This method will return a table with a line type WDR_CONTEXT_CHANGE as I had mentioned.

Finally once you leave the view, call

lo_context->reset_context_change_log( ) to reset the context log.

Thanks,

Ajay Bose

former_member215344
Contributor
0 Kudos

Hi Matteo,

Check the component DEMO_CONTEXT_CHANGES in the SWDP_DEMO package for sample code.

Thanks,

Ajay Bose

Answers (2)

Answers (2)

former_member219762
Contributor
0 Kudos

Hi ,

Get selected elements by method GET_SELECTED_ELEMENTS and store as attribute. So compare past and present values to get which rows are selected or deselected.

Regards,

Sreenivas.

matteo_montalto
Contributor
0 Kudos

Yea, I thought about it... but think it's kinda "expensive" as for any lead selection I have continuosly to compare "old" data w.r.t. the newer ones.

Anyway, it's a feasible solution.

former_member184578
Active Contributor
0 Kudos

Hi,

Check this Help :  http://help.sap.com/saphelp_nw73/helpdata/en/f9/64c0410c2dcc17e10000000a155106/content.htm

In this the example shown for link to action events, similarly you can use for Table event handler.

Hope this helps u.,

Regards,

Kiran