Skip to Content
avatar image
Former Member

ABAP Web Dynpro - get the selected table values

Hello,

I'm new at Abap Web Dynpro and I try to get some information of an ALV when I click on a button. In my layout view I have a ViewContainerUIElement where I the ALV is implemented. Under this element I have a button that should read the selected data row in the ALV.

I tried this to get the data:

CHANGING is my ALV-tab.

DATA: context_element type ref to if_wd_context_element, 
      context_data    type ref to if_wd_context_node.

context_element = wdevent->get_context_element( 'CHANGING' ).
context_data    = wdevent->get_context_element( 'CHANGING' ).


*then call the get_index method..
context_element->get_index( ).
context_data->get_selected_elements( ).

When I test the Web Dynpro in IE it does not work.

Can anybody helps me?

Regards, Markus

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • Best Answer
    avatar image
    Former Member
    May 09, 2008 at 07:00 AM

    Hey Naresh,

    thank you for your reply.

    I check your solution, but I don't know what is meant by

    Wd_This->Element_Appr

    ?

    What is Element_Appr?

    Can you help me, please.

    Thanks!

    Regards, Markus

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Markus

      here Appr is node in context of my code.

      In your case the node is 'changing'. i forgot to change that.

      if you see under the attributes tab wd_this ref to If_<Viewname>.

      and if you click on If_<Viewname> you will see system generated code where each node in context is declared like Element_<node>

      so code will be like this .

      data:

      Node_Appr type ref to If_Wd_Context_Node,

      Elem_Appr type ref to If_Wd_Context_Element,

      Stru_Appr type Wd_This->Element_changing .

      Node_Appr = wd_Context->get_Child_Node('CHANGING' ).

      Elem_Appr = Node_Appr->get_Element( ).

      Elem_Appr->get_Static_Attributes(

      importing

      Static_Attributes = Stru_Appr ).

      Regards

      Naresh

  • avatar image
    Former Member
    May 08, 2008 at 03:06 PM

    Hi Markus

    Try this.

    data:

    Node_Appr type ref to If_Wd_Context_Node,

    Elem_Appr type ref to If_Wd_Context_Element,

    Stru_Appr type Wd_This->Element_Appr .

    Node_Appr = wd_Context->get_Child_Node('CAHNGING' ).

    Elem_Appr = Node_Appr->get_Element( ).

    Elem_Appr->get_Static_Attributes(

    importing

    Static_Attributes = Stru_Appr ).

    Stru_Appr here will contain your slected row.

    Regards

    Naresh

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 08, 2008 at 02:12 PM

    Hello,

    Please try this:

      DATA: lr_node      TYPE REF TO   if_wd_context_node,
            lr_element   TYPE REF TO   if_wd_context_element,
      DATA: lt_element   TYPE          wdr_context_element_set.
      DATA: lv_index     TYPE          i.
    
      lr_node = wd_context->get_child_node( 'CHANGING' ).
    
      lt_element = lr_node->get_selected_elements( including_lead_selection = abap_false ).
    
    * read selected dataset
      LOOP AT lt_element INTO lr_element.
    
        lv_index = lr_element->get_index( ).
        IF lv_index IS NOT INITIAL.
    *      lr_element->get_attribute(  ).
        ENDIF.
      ENDLOOP.
    

    Regards,

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 08, 2008 at 02:59 PM

    Thank you David for your quick reply.

    I implemented your solution and at first it looks very good. But in Debug-Mode the lt-element is empty.

    I don't know where the problem is.

    Regards, Markus

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 13, 2008 at 08:23 AM

    Thank you, now it works!

    Regards, Markus

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 13, 2008 at 10:36 AM

    Hi,

    make the cardinality for table as 0:n.(i.e for node for which table is bound).

    For table set the property selection_mode to multinolead.

    then implement the coding.

    If there is a node called user_entities for which table is bound then

    DATA: lo_nd_user_entities TYPE REF TO if_wd_context_node,

    lt_elements TYPE wdr_context_element_set,

    lo_elements TYPE REF TO if_wd_context_element,

    ls_user_entities TYPE wd_this->element_user_entities.

    lo_nd_user_entities = wd_context->get_child_node( name = wd_this->wdctx_user_entities ).

    lt_elements = lo_nd_user_entities->get_selected_elements( ).

    LOOP AT lt_elements INTO lo_elements.

    • Get Contents of selected Lines............

    CALL METHOD lo_elements->get_static_attributes

    IMPORTING

    static_attributes = ls_user_entities.

    endloop.

    Add comment
    10|10000 characters needed characters exceeded