Skip to Content

how can i get the selected row in abab webdynpro table?

hi

i have a table in my webdynpro screen. The employee can add rows to this table.

the new line is always added at the buttom of the table - i mean it is always added as the last row.

i want to let the user the option to add rows bwtween 2 existing rows - the user will mark the row and press the vutton "insert row" and a new row will be entered between the existing rows (like in EXCEL ). Is there a way to do that ?

Thanks

Ami .

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Dec 24, 2012 at 09:38 AM

    steps to do:

    1. get lead selection of node by using  if_wd_context_node method get_lead_seelection_index.

    2. get table using if_wd_context_node method get_static_attribute_table.

    3  you can put all rows of table greater than lead_selation into another ( temporary ) internal table then append a new row in main internal table.

    4. put all data from temporary internal table into main table and bind main table with node using method bind_table.

    if helpful reward point

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 24, 2012 at 01:03 PM

    Hi,

    I am sharing a code sample to get the selected rows of a table. Here we have a table with flight booking details, user can select more than one row.

    Please refer the code below:

      DATA: lo_nd_bookings TYPE REF TO if_wd_context_node,
            it_selrows  TYPE wdr_context_element_set,
            wa_selrows LIKE LINE OF it_selrows.
      DATA ls_bookings TYPE wd_this->element_bookings.
      DATA lt_bookings TYPE wd_this->elements_bookings.
    *   navigate from <CONTEXT> to <BOOKINGS> via lead selection
      lo_nd_bookings = wd_context->get_child_node( name = wd_this->wdctx_bookings ).

    *   @TODO handle not set lead selection
      IF lo_nd_bookings IS INITIAL.
      ELSE.
        CALL METHOD lo_nd_bookings->get_selected_elements
    *          EXPORTING
    *            including_lead_selection = ABAP_FALSE
          RECEIVING
            set                      = it_selrows
            .
        LOOP AT it_selrows INTO wa_selrows.
          CALL METHOD wa_selrows->get_static_attributes
            IMPORTING
              static_attributes = ls_bookings.
          APPEND ls_bookings TO lt_bookings.
          CLEAR  ls_bookings.
        ENDLOOP.

      ENDIF.

    Now you know the row which was selected. Get the data from the context node in the internal table, add a blank row in the internal table at the correct index and again bind the internal table to your context node.

    Regards,

    Sayan

    Add comment
    10|10000 characters needed characters exceeded