cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic creation of Dropdown by Index in the view

Former Member
0 Kudos

Hi,

Please help me how to create Dropdown by Index dynamically.

The scenario is in a view, part of view is Static and other part is Dynamic.

Dynamic part display depends on entry selected from Static part of the view.

I am using method WDDOMODIFYVIEW to implement this. I could successfully generate Group, Caption, TextView view

element dynamically but with Dropdown by Index, I am getting runtime error.

New Dropdown by Index will belong to Dyanmically generated Group in 'ROOTELEMENTCONTAINER' and new Context node will be created in CONTEXT for Dynamic Dropdown by Index .

Thanks, in advance ,for your help.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Thanks Amit and Lekha for your replies.

I tried the code but still I am getting the same error.


  lr_rootnode_info = wd_context->get_node_info( ).
  lr_rootnode_info = lr_rootnode_info->get_child_node( 'ADD_DATA' ).

  call method lr_rootnode_info->add_new_child_node( exporting name = lv_node_name                                                                    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_rootnode_info ).
****----------------Get instance of new node
  concatenate 'ADD_DATA.' lv_node_name INTO lv_child_node.
  lr_dyn_node = wd_context->get_child_node( name = lv_child_node ).

***----------------Prepare properties of attribute and add to context node
*data:lo_nd_add_data type ref to if_wd_context_node,
*     lo_nd_lv_node_name type ref to  if_wd_context_node,
*     lo_el_lv_node_name type ref to  if_wd_context_element.
*
*lo_nd_add_data = wd_context->get_child_node( name = wd_this->wdctx_add_data ).
*lo_nd_lv_node_name = lo_nd_add_data->get_child_node( name = lv_node_name ).
*lo_el_lv_node_name = lo_nd_lv_node_name->get_element(  ).

  concatenate is_char-descr_char 'ID' into lv_attname.
  translate lv_attname to upper case.
  condense lv_attname no-gaps.

  lr_attribute-name = lv_attname.
  lr_attribute-type_name = 'STRING'.
  lr_attribute-value_help_mode = '0'.

  lr_rootnode_info->add_attribute( exporting attribute_info = lr_attribute ).

  lr_element = lr_dyn_node->create_element( ).
  lr_dyn_node->bind_element( new_item = lr_element
                             set_initial_elements = abap_true ).

  concatenate lv_node_name '.' lv_attname into   lv_bindtext.
  lr_ddbyidx = CL_WD_DROPDOWN_BY_IDX=>NEW_DROPDOWN_BY_IDX( id = iv_name
                                                view = ir_view
                                                label_for = iv_textviewid
                                                bind_texts = lv_bindtext ).

  lr_row_grid_data = cl_wd_grid_data=>new_grid_data( element = lr_ddbyidx ).

*******To set the TextView to the Group_2

  lr_group2->add_child( lr_ddbyidx ).

Please help.

Thanks.

Edited by: Trupti Kallurwar on Oct 26, 2009 9:14 PM

Former Member
0 Kudos

hi trupti ,

try refering to WIKI and follow these steps :

1 in WD DOMODIFY of ur view , write the piece of code for dynamic generation of ur dropdown

2 U need to include one transparent container , say 'TC_SYSTEM' in ur view in which the dynamic dropdowns wud get added.

u need to use cl_wd_dropdown_by_idx for generating the dynamic drop down by index

the name of the attribute here in WIKI :is SYS_ID , which u have added to ur dynamically created node

using CONCATENATE

do revert to me in case of clarification

regards,

amit

Former Member
0 Kudos

Hi Amit,

Thanks for your help.

I followed the same code in wiki except instead of adding dynamic Dropdown list to

new Container, I am using 'ROOTELEMENTCONTAINER'.

Please refer to the code in WDDOMODIFYVIEW()

data: lr_rootnode_info TYPE REF TO if_wd_context_node_info,

lr_dyn_node TYPE REF TO if_wd_context_node.

(Note - 'ADD_DATA' is static Context Node in View to which all dynamically created nodes

will belong )

lr_rootnode_info = wd_context->get_node_info( ).

lr_rootnode_info = lr_rootnode_info->get_child_node( 'ADD_DATA' ).

call method lr_rootnode_info->add_new_child_node( exporting name = lv_node_name 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_rootnode_info ).

****----


Get instance of new node

  • lr_dyn_node = wd_context->get_child_node( name = lv_node_name ).

concatenate 'ADD_DATA.' lv_node_name INTO lv_child_node.

lr_dyn_node = wd_context->get_child_node( name = lv_child_node ). (Getting runtime error at this statement)

Error says Subnode 'SELECT.ADD_DATA.ISODOCUMENTCATEGORY does not exist ' where

SELECT - View name

ADD_DATA - Static Context node

ISODOCUMENTCATEGORY - Dynamic Context node under ADD_DATA

Thank you.

Edited by: Trupti Kallurwar on Oct 20, 2009 5:23 PM

Former Member
0 Kudos

Hi,

lr_rootnode_info = wd_context->get_node_info( ).
lr_rootnode_info = lr_rootnode_info->get_child_node( 'ADD_DATA' ).
call method lr_rootnode_info->add_new_child_node( exporting name = lv_node_name 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_rootnode_info ).
****----------------Get instance of new node
* lr_dyn_node = wd_context->get_child_node( name = lv_node_name ).
concatenate 'ADD_DATA.' lv_node_name INTO lv_child_node.
lr_dyn_node = wd_context->get_child_node( name = lv_child_node ). (Getting runtime error at this statement)

Error says Subnode 'SELECT.ADD_DATA.ISODOCUMENTCATEGORY does not exist ' where 
SELECT - View name
ADD_DATA - Static Context node
ISODOCUMENTCATEGORY - Dynamic Context node under ADD_DATA

As per the above, You have successfully created the ADD_DATA node right(design time).

Initially while you are creating a subnode what is the lv_node_name that you are trying to pass in this statement

call method lr_rootnode_info->add_new_child_node( exporting name = lv_node_name is_mandatory = abap_false

I guess you concatenate statement should be above this to pass the lv_node_name while creation itself. As you didnot pass it,

it says that there is no node named on it.

lr_rootnode_info = lr_rootnode_info->get_child_node( 'ADD_DATA' ).
concatenate 'ADD_DATA.ISODOCUMENTCATEGORY' INTO lv_node_name.  "Try to pass the viewname also N check it
call method lr_rootnode_info->add_new_child_node( exporting name = lv_node_name is_mandatory = abap_false

Hope this is clear.

Regards,

Lekha.

Former Member
0 Kudos

Hi Trupti ,

I am creating my dynamic context node directly under the context in my example & therafter I am adding context attributes to it .

Since in ur case , u r having a static node ADD_DATA and u want to create ur dynamic context nodes and attributes under it ,

u need to modify ur code a little bit :



  DATA lo_nd_add_data           TYPE REF TO if_wd_context_node.
    DATA lo_nd_lv_node_name TYPE REF TO if_wd_context_node.
    DATA lo_el_lv_node_name  TYPE REF TO if_wd_context_element.
*   navigate from <CONTEXT> to <ADD_DATA> via lead selection
    lo_nd_add_data = wd_context->get_child_node( name = wd_this->wdctx_add_data ).

*   navigate from <ADD_DATA> to <LV_NODE_NAME> via lead selection
    lo_nd_lv_node_name = lo_nd_add_data->get_child_node( name = wd_this->wdctx_lv_node_name ).

*   get element via lead selection
    lo_el_lv_node_name = lo_nd_lv_node_name->get_element(  ).

thn u shd not get the run time error . I hope u r clear wid the problem

regards,

amit

Former Member
0 Kudos

hi Triputi ,

for dynamic creation of the dropdown by index in ur view refer this wiki :

http://wiki.sdn.sap.com/wiki/x/9gQ5C

for dynamic node creation , pls refer :

https://www.sdn.sap.com/irj/scn/elearn?rid=/library/uuid/201ddd3b-b4ce-2b10-8883-880ae8147f89&overri...

Check this elearning

https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/201ddd3b-b4ce-2b10-8883-880ae814...

Check these blogs as well :

Link: [Dynamic Programming in Web Dynpro ABAP - Introduction and Part I |http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3417100)ID1962293250DB11858743607560747072End?blog=/pub/wlg/2888]

Link: [Dynamic Programming in Web Dynpro ABAP - Part II |http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3417100)ID1962293250DB11858743607560747072End?blog=/pub/wlg/2915]

regards,

amit

Edited by: amit saini on Oct 20, 2009 7:24 AM