cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP: dynamic context node + attribute for DROP_DOWN_BY_KEY

Former Member
0 Kudos

Hello,

I need to create a Node with attributes dynamically and than assign it to a DROP_DOW_BY_KEY element in ABAP.

I create drop down this way:


drop_down_figure = cl_wd_dropdown_by_key=>new_dropdown_by_key( bind_selected_key = 'REPOSITORY.FIGURES' on_select = 'GET_OPERATOR' ).
  cl_wd_grid_data=>new_grid_data( element = drop_down_figure ).
  ui_container->add_child( drop_down_figure ).

However, here I bind to REPOSITORY.FIGURES. Instead of doing this I need to bind it to an attribute that I create.

I can access wd_context but I am not sure how to create a node in wd_context, then attribute for that node that will contain items for drop down.

bind_selected_key is type of String. If I create a node with attribute how do I cast it to a String so I can pass it to a constructor of a drop down?

Thank you.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Does anybody has an example how to create a context node with an attribute dynamically?

Thank you.

Former Member
0 Kudos

Georgy,

Please follow this perefect tutorial for dynamic context,

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/4e3ad5fc-0901-0010-3c9e-e9b...

Thanks,

Raj.

Former Member
0 Kudos

Hello Raj,

Unfortunately, the above example is for Java WebDynpro and not ABAP.

Thanks.

srinivasa_raghavachar
Participant
0 Kudos

Hi Georgy,

There is a 3 - series weblog for this.

The first one is:

/people/thomas.szcs/blog/2005/12/28/dynamic-programming-in-web-dynpro-abap--introduction-and-part-i-understanding-ui-elements

The following are the the general steps for creating a node and table where table name is input by the user:

DATA:

  • UI Elements

group_1 TYPE REF TO cl_wd_uielement_container,

new_tab TYPE REF TO cl_wd_table,

  • Context Nodes

dyn_node TYPE REF TO if_wd_context_node,

tabname_node TYPE REF TO if_wd_context_node,

  • Node Info

rootnode_info TYPE REF TO if_wd_context_node_info,

  • Data Reference (for internal table)

stru_tab TYPE REF TO data,

  • String (for table name)

tablename TYPE string.

FIELD-SYMBOLS:

<tab> TYPE table.

1) * get node info of context root node

rootnode_info = wd_context->get_node_info( ).

2) * create sub node named TEST1 of structure (tablename)

cl_wd_dynamic_tool=>create_nodeinfo_from_struct(

parent_info = rootnode_info

node_name = tablename

structure_name = tablename

is_multiple = abap_true ).

3) * get instance of new node

dyn_node = wd_context->get_child_node( name = tablename ).

4) ***** create new UI element table *******************************************************

new_tab = cl_wd_dynamic_tool=>create_table_from_node(

ui_parent = group_1

table_id = 'TESTTAB'

node = dyn_node ).

5) ***** fill context node with data *******************************************************

  • create internal table of (tabletype)

CREATE DATA stru_tab TYPE TABLE OF (tablename).

ASSIGN stru_tab->* TO <tab>.

  • Get table content

SELECT * FROM (tablename) INTO CORRESPONDING FIELDS OF TABLE <tab>.

  • Bind internal table to context node.

dyn_node->bind_table( <tab> ).

Regards,

Srini.

Former Member
0 Kudos

Hello Srini,

Thank you!