cancel
Showing results for 
Search instead for 
Did you mean: 

SET LEAD SELECTION

Former Member
0 Kudos

Hi All ,

I am generating dynamic dropdowns in my WDA .

Now I want to set the values in these dropdowns to particular index .

I am doing the following piece of coding :


Do n times

here n is the counter , that many dropdowns shud be generated



DATA : lv_node type string value 'SYS' .
  CONCATENATE lv_node wd_this->count_sys INTO lv_node.
  wd_this->count_sys = wd_this->count_sys + 1.


 DATA: dyn_node TYPE REF TO if_wd_context_node.
  dyn_node = wd_context->get_child_node( name = lv_node ).

after that my piece of code to genertate the dynamic node .

now I am using lead selection for each dropdown as follows


  dyn_node->set_lead_selection_index( lv_index ).
EndDo.
 

suppose Do ..EndDo runs 4 times , so 4 dynamic dropdowns are generated , suppose 1st dropdown is set to lead selction 5 , 2nd to 7th , 3rd to 1st and 4th to 10th

now the problem is the lead selection for all the dropdowns is set to the last dynamic dropdown index , ie in this case all the dropdowns are set to lead index 10 . can any 1 help me , how to set index correctly .

regards,

amit

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

I had solved the problem by myself ,

had to increment counter in select query

Former Member
0 Kudos

Hi,

I think you are using the SAME attribute to all the dropdowns. hence it is taking the last set value.

Is that so. what are attirbutes under that node.

Or

Get the reference of the dropdown then set the index.

Regards,

Lekha.

Former Member
0 Kudos

hi lekha ,

i m dynamically generating context node

suppose i want to generate 4 nodes .. so I am generating 4 nodes

SYS00 , SYS01, SYS02 , SYS03

nw dynamic attribute SYS_ID for each node ..

Former Member
0 Kudos

this is what I am coding :


  DATA : lv_systemcount1    type Z2TS_COUNT ,
         lv_modulecount1    type z2ts_count ,
         lv_texteditcount1  type z2ts_count ,
         lv_texteditcount   type z2ts_count .


 select  MAX( count1 ) from z2ts_usersys into
      lv_systemcount1 where userid EQ WD_COMP_CONTROLLER->G_EDIT_USERID
   AND
       role_id EQ wd_comp_controller->G_EDIT_ROLEID
 AND site_id EQ  wd_comp_controller->G_EDIT_SITEID .

   wd_this->count1  = lv_systemcount1 .
   wd_this->count13 = lv_systemcount1 .


 do lv_systemcount1 times .


DATA: lr_container      TYPE REF TO cl_wd_uielement_container,
        lr_group          TYPE REF TO cl_wd_group,
        lr_caption_group  TYPE REF TO cl_wd_caption,
        lr_dropdown      TYPE REF TO cl_wd_dropdown_by_idx,
        lr_node_info      TYPE REF TO if_wd_context_node_info,
        lr_node           TYPE REF TO if_wd_context_node,
        lr_element        TYPE REF TO if_wd_context_element,
        lr_attribute_info TYPE wdr_context_attribute_info,
        lo_dd_ind      TYPE REF TO cl_wd_dropdown_by_idx,
        content           TYPE string,
        attribute_name    TYPE string,
        lv_textview_id    TYPE string ,
          dd_indx_id     TYPE string .




  lr_container ?= wd_this->mr_view->get_element('TC_SYSTEM' ).

*  CHECK first_time = abap_true.

*    generating dynamic node with UNIQUE ID
  DATA : lv_node type string value 'SYS',
        lv_sap type string .
*  *internal table declaration
  DATA : itab_sys     TYPE STANDARD TABLE OF z2ts_systems .
* work area declaration
  DATA : wa_sys       TYPE  z2ts_systems .

  CONCATENATE lv_node wd_this->count_sys INTO lv_node.
  wd_this->count_sys = wd_this->count_sys + 1.

  lr_node_info = wd_context->get_node_info( ).

  CALL METHOD lr_node_info->add_new_child_node
    EXPORTING
      name                         = lv_node
      is_mandatory                 = abap_false
      is_multiple                  = abap_true
      is_multiple_selection        = abap_true
      is_singleton                 = abap_false
      is_initialize_lead_selection = abap_true
      is_static                    = abap_false
    RECEIVING
      child_node_info              = lr_node_info.

**    Get instance of new node

  DATA: dyn_node TYPE REF TO if_wd_context_node.
  dyn_node = wd_context->get_child_node( name = lv_node ).

* Dynamic transparent container and text edit
  DATA: lo_container TYPE REF TO cl_wd_uielement_container,
        lo_dropdown TYPE REF TO cl_wd_dropdown_by_idx .
*        lr_attribute_info TYPE wdr_context_attribute_info,
*        lr_element TYPE REF TO if_wd_context_element.

  lo_container ?= wd_this->mr_view->get_element( 'TC_SYSTEM' ).

*** Prepare properties of attribute & add to context node CHILD
  lr_attribute_info-name = 'SYS_ID'.
  lr_attribute_info-type_name = 'STRING'.
  lr_attribute_info-value_help_mode = '0'.

  lr_node_info->add_attribute(
  EXPORTING attribute_info = lr_attribute_info ).

  lr_element = dyn_node->create_element( ).

 dyn_node->bind_element( new_item             = lr_element
                         set_initial_elements = abap_false ).


  wd_this->count = wd_this->count + 1.
  dd_indx_id = 'DD_1'.
  CONCATENATE dd_indx_id wd_this->count INTO dd_indx_id.

  CONCATENATE lv_node '.SYS_ID' INTO LV_SAP.
   lo_dropdown = cl_wd_dropdown_by_idx=>new_dropdown_by_idx(
   bind_texts           =  LV_SAP
   id = dd_indx_id view = wd_this->mr_view ).



*   append initial line to internal table
    APPEND INITIAL LINE TO itab_sys .
*   populating internal table
    SELECT *
     FROM z2ts_systems
      APPENDING TABLE itab_sys.
* bind internal table with dynamic node
  dyn_node->bind_table( itab_sys ) .

  DATA lv_sysid TYPE Z2TS_SYSID1.
*

select  single SYS_ID from z2ts_usersys into
      lv_sysid where userid EQ WD_COMP_CONTROLLER->G_EDIT_USERID
   AND
       role_id EQ wd_comp_controller->G_EDIT_ROLEID
 AND site_id EQ  wd_comp_controller->G_EDIT_SITEID and
       count1 EQ wd_this->count1 .

  DATA : lv_index type i .

    clear  wa_sys.
  LOOP AT itab_sys INTO wa_sys.
    IF wa_sys-SYS_ID =  lv_sysid.
      lv_index = sy-tabix.
    ENDIF.
   clear  wa_sys.

  ENDLOOP.
  dyn_node->set_lead_selection_index( lv_index ).


  cl_wd_matrix_head_data=>new_matrix_head_data( element = lo_dropdown ).

  lo_container->add_child( lo_dropdown ).



  ENDDO.

any pointers

Former Member
0 Kudos

Hi,

I guess itab_sys has the dyn_node information.


LOOP AT itab_sys INTO wa_sys.
 IF wa_sys-SYS_ID = lv_sysid. 
lv_index = sy-tabix. ENDIF. clear wa_sys. 
ENDLOOP. 
dyn_node->set_lead_selection_index( lv_index ).  "Why this is written outside. the last vallue of sytabix is stored and hence it is
set to teh last value alsywas. Better keep this statement inzide the loop to have the
LV_INDEX set to node can be changed.
 cl_wd_matrix_head_data=>new_matrix_head_data( element = lo_dropdown ). lo_container->add_child( lo_dropdown ). ENDDO.

Regards,

Lekha.

Former Member
0 Kudos

it is not working

Former Member
0 Kudos

Hi,

The table that you are looping does this have dyn node instance.

For ex: if you have created 4 nodes for 4 dropdowns, are you storing this dyn node instance in any table.

One thing you do,

store both the dyn nodes and droddown instacnes in one node (0:N) which has the respective types to store information.

Now loop at this table, and set the lead selection.

Regards,

Lekha.