cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with table cell editors - Dropdown by Index, getting lead selection

Former Member
0 Kudos

Hi experts,

I have a table editor with 5 columns

1st column is a Drop Down byIndex.

My contex looks like this


AS_DATA(Parent Node cardinality 1.1, selection 0-1)
      HEADER (NODE)
      DETAILS(NODE cardinality 0..n, selection 0-1)
         ACTIVITY_TYPES (NODE cardinality 0..n selection 0-1 ) "node for drop down
         description - attribute
         unit
         quantity

i have bound details node to table data source.

i have a tool bar button 'Add Line item' which will add a new line item to the table.

(i am adding a blank line to the table that is bound to table )

Its working fine. but when ever i add more than one row, the selection made in the previous rows drop down is lost.

its initializing. where could be the problem.

My code


data LO_ND_INV_TYPE type ref to IF_WD_CONTEXT_NODE.
  data LO_EL_INV_TYPE type ref to IF_WD_CONTEXT_ELEMENT.
  data LS_INV_TYPE type WD_THIS->ELEMENT_INV_TYPE.
  data LV_INV_TYPE type WD_THIS->ELEMENT_INV_TYPE-INV_TYPE.
  data LO_ND_DETAILS type ref to IF_WD_CONTEXT_NODE.
  data LT_DETAILS type WD_THIS->ELEMENTS_DETAILS.
  data LS_DETAILS like line of LT_DETAILS.
  data:  WD_NODE type ref to IF_WD_CONTEXT_NODE,
        LR_ELEMENT type ref to IF_WD_CONTEXT_ELEMENT.
  data LO_ND_INV_PATTERN type ref to IF_WD_CONTEXT_NODE.
  data LO_EL_INV_PATTERN type ref to IF_WD_CONTEXT_ELEMENT.
  data LS_INV_PATTERN type WD_THIS->ELEMENT_INV_PATTERN.
  data LV_INV_PAT type WD_THIS->ELEMENT_INV_PATTERN-INV_TYPE.
  data LO_ND_ACTIVITY_TYPES type ref to IF_WD_CONTEXT_NODE.
  data LT_ACTIVITY_TYPES type WD_THIS->ELEMENTS_ACTIVITY_TYPES.
  data LW_ACTIVITY_TYPES type WD_THIS->ELEMENT_ACTIVITY_TYPES.
    data LO_EL_ACTIVITY_TYPES type ref to IF_WD_CONTEXT_ELEMENT.

*     navigate from <CONTEXT> to <DETAILS> via lead selection
    LO_ND_DETAILS = WD_CONTEXT->PATH_GET_NODE( PATH = `AS_DATA.DETAILS` ).

    LO_ND_DETAILS->GET_STATIC_ATTRIBUTES_TABLE(
      importing TABLE = LT_DETAILS ).

* Append an empty row to lt_details
    append LS_DETAILS to LT_DETAILS.

    LO_ND_DETAILS->BIND_TABLE(
    NEW_ITEMS = LT_DETAILS ).
* Get values for dropdown
call method WD_ASSIST->GET_ACTIVITY_TYPE
      exporting
        I_INV_CAT_ID     = LV_INV_PAT
      importing
        ET_ACTIVITY_TYPE = LT_ACTIVITY_TYPES.


    LW_ACTIVITY_TYPES-ID = 'Select a Activity type'.
    LW_ACTIVITY_TYPES-TEXT = 'Select a Activity type'.
    insert LW_ACTIVITY_TYPES into LT_ACTIVITY_TYPES index 1.

    loop at LT_DETAILS into LS_DETAILS.
      LV_TABIX = SY-TABIX.

      LR_ELEMENT = LO_ND_DETAILS->GET_ELEMENT( LV_TABIX ).

      WD_NODE = LR_ELEMENT->GET_CHILD_NODE( 'ACTIVITY_TYPES' ).
*lv_index = wd_node->get_lead_selection_index( ). " it is dumping at this statement when i try to get lead selection
      WD_NODE->BIND_TABLE( NEW_ITEMS =  LT_ACTIVITY_TYPES ). " data for dropdown
    endloop.

any clue on what am i missing will be appreciated.

I am getting dump when i try to get the lead selection

Ajay

Accepted Solutions (1)

Accepted Solutions (1)

saravanan_narayanan
Active Contributor
0 Kudos

Hello Ajay,

In your code, you are binding the Activity Types for all the rows again. Binding of table will lead to the lose of selection.

For adding a new record, do the following


    LO_ND_DETAILS = WD_CONTEXT->PATH_GET_NODE( PATH = `AS_DATA.DETAILS` ).
data lo_el_details type ref to if_wd_context_element.

lo_el_details = lo_nd_details->create_element( ).
lo_el_details = lo_nd_details->bind_element( new_item = lo_el_details set_initial_elements = abap_false ).


* Get values for dropdown
call method WD_ASSIST->GET_ACTIVITY_TYPE
      exporting
        I_INV_CAT_ID     = LV_INV_PAT
      importing
        ET_ACTIVITY_TYPE = LT_ACTIVITY_TYPES.
 
 
    LW_ACTIVITY_TYPES-ID = 'Select a Activity type'.
    LW_ACTIVITY_TYPES-TEXT = 'Select a Activity type'.
    insert LW_ACTIVITY_TYPES into LT_ACTIVITY_TYPES index 1.
 

      WD_NODE = lo_el_details ->GET_CHILD_NODE( 'ACTIVITY_TYPES' ).
      WD_NODE->BIND_TABLE( NEW_ITEMS =  LT_ACTIVITY_TYPES ). " data for dropdown
    endloop.

BR, Saravanan

Former Member
0 Kudos

Hi Saravanan

Many thanks for your inputs. It was bang on. i was doing a mistake by binding the node again....

Regards,

Ajay

Answers (1)

Answers (1)

shahid
Product and Topic Expert
Product and Topic Expert
0 Kudos

You only have only one option in the DDI to display in the example. when you have multiple values

i assume that by adding an empty row like this will lose the SELECTION MADE in DDI. (Correct me If i am wrong)

somehow i believe that we need to bind the DD values using SET LEAD SELECTION INDEX METHOD FOR THE DDI when they are already selected and trying to BIND.

*LO_ND_DETAILS->GET_STATIC_ATTRIBUTES_TABLE(*
      *importing TABLE = LT_DETAILS ).*
 
** Append an empty row to lt_details*
    *append LS_DETAILS to LT_DETAILS.*
 
    *LO_ND_DETAILS->BIND_TABLE(*
 
    *NEW_ITEMS = LT_DETAILS ).*

even though the above code will have the selected value, the SELECTIONS MADE will be initialize.

you need to bind it explicitly.

you have to create an element and bind the DDI values for adding an row as SARAVANAN said.

or i guess you can continue with you code but need to use SET LEAD to display the correct SELECTIONS MADE

loop at LT_DETAILS into LS_DETAILS.
      LV_TABIX = SY-TABIX.
 
      LR_ELEMENT = LO_ND_DETAILS->GET_ELEMENT( LV_TABIX ).
 
      WD_NODE = LR_ELEMENT->GET_CHILD_NODE( 'ACTIVITY_TYPES' ).
      WD_NODE->BIND_TABLE( NEW_ITEMS =  LT_ACTIVITY_TYPES ). " data for dropdown

*" try to set the desired value in the DDI when you have multiple values using SET LEAD*

    endloop.