SAP/ABAP info: Web Dynpro for ABAP Table Links
Goal
You want to create a table and you have links in your table (LinkToAction). You click on a link and you want to do something with the line values in the action.
 

Solution

1. You create an action
2. In the action you can use the following line:
ls_context_element = wdevent->get_context_element( 'CONTEXT_ELEMENT').

With this you get the actual context element - the table line.
This little piece of knowledge took me 3 hours to get...

Here is the full source code:

method onactionclick_link .

  data lv_land1 type land1.

  data: ls_context_element type ref to if_wd_context_element.
*  ls_context_element = wdevent->get_data( name = 'CONTEXT_ELEMENT' ).
  ls_context_element = wdevent->get_context_element( 'CONTEXT_ELEMENT').

  data: lv_matnr type matnr.
  call method ls_context_element->get_attribute
    exporting
      name  = 'LAND1'
    importing
      value = lv_land1.


  data lo_nd_local type ref to if_wd_context_node.
  data lo_el_local type ref to if_wd_context_element.
  data ls_local type wd_this->element_local.
  data lv_text like ls_local-text.
* navigate from  to  via lead selection
  lo_nd_local = wd_context->get_child_node( name = wd_this->wdctx_local ).

* get element via lead selection
  lo_el_local = lo_nd_local->get_element(  ).

* get single attribute
  lo_el_local->set_attribute(
    exporting
      name =  `TEXT`
      value = lv_land1 ).




endmethod.

          
Some keywords: web dynpro abap onaction on action wdevent wd event action linktoaction link to action problem help solution
 

 

 
Published on zbalai.com in 2008.