cancel
Showing results for 
Search instead for 
Did you mean: 

Problem: Internal table and Drop-Down-List

Former Member
0 Kudos

Hi Gurus,

I am using a internal table, for calling a FM, which require Internal table as its parameter.

e.g. pt_material, its structur is (key, value)

how can i show this Table into a Drop-Down-List, which one is better?

Best Regards

Shuo

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You can use DropDownBy key... Please refer to the sample code in WDDOINT method...

method WDDOINIT .
  data:
    Node_Node1 type ref to If_Wd_Context_Node,
    Info_Node1 type ref to IF_WD_CONTEXT_NODE_INFO,
    value_set type TIHTTPNVP,
    wa_value_set TYPE LINE OF TIHTTPNVP.

  Node_Node1 = wd_Context->get_Child_Node( Name = IF_MAIN=>wdctx_Node1 ).

  Info_Node1 = Node_Node1->get_node_info( ).

  wa_value_set-name = `01`.
  wa_value_set-value = `Consultant`.
  APPEND wa_value_set to value_set.
  clear wa_value_set.
  wa_value_set-name = `02`.
  wa_value_set-value = `Senior Consultant`.
  APPEND wa_value_set to value_set.
  clear wa_value_set.
  wa_value_set-name = `03`.
  wa_value_set-value = `Manager Projects`.
  APPEND wa_value_set to value_set.
  clear wa_value_set.

  Info_Node1->set_attribute_value_set( name = 'DESIGNATION'
        value_set = value_set ).


endmethod.

Hope this helps,

Best regards,

Ravikiran.

Former Member
0 Kudos

Hi Ravikiran,

Thanks for your reply.

Sorry, my problem was, the internal table is dynamic.

structur is Key | name | value

i want to Output parameter pt_material-value in the drop-down, is that possible?

Thanks

Best Regards

Shuo

Former Member
0 Kudos

Hi,

Loop at your pt_material internal table and build the internal table (Name-Value pair) and pass to the attribute of the node as suggested before...

Hope I am clear..

Regards,

Ravikiran.

Former Member
0 Kudos

Hi,

Lets say you have a context attribute 'VALUE' whose values you wish to display as a drop down. After you call the function module and get the data in internal table pt_material, include the following code:

data: lr_node type ref to if_wd_context_node,

lt_valueset type table of wdr_context_attr_value,

ls_valueset type wdr_context_attr_value,

lr_nodeinfo type ref to if_wd_context_node_info,

wa_material type pt_material.

lr_node = wd_context->get_child_node('NODE').

lr_nodeinfo = lr_node->get_node_info( ).

loop at pt_material into wa_material.

ls_valueset-value = wa_material-key.

ls_valueset-text = wa_material-value.

append ls_valueset to lt_valueset.

endloop.

lr_nodeinfo->set_attribute_value_set(

exporting

name = 'VALUE'

valueset = lt_valueset

).

This code is for a drop down by key UI element. In your view, for the dropdownby key element, bind the selectedKey property to 'VALUE' attribute of your context node.

I hope this is what you are looking for.

Regards,

Nithya

Former Member
0 Kudos

Hi Nithya,

you have got my problem. Your Answer was very helpful.

Thanks a lot!

Best Regards

Shuo

Answers (1)

Answers (1)

mohammed_anzys
Contributor
0 Kudos

Hi

Create a node of your internal structure type and bind the values from the internal table to the node using bind_table method of if_wd_context_node.Then bind this node to your dropdown node the UI

Thanks

Anzy

Former Member
0 Kudos

Hi Anzy,

can you give an example, how to use the bind_table method?

thanks a lot.

Regards

Shuo

mohammed_anzys
Contributor
0 Kudos

Hi Shuo,

Go through the following code.

data:uitab type ref to if_wd_context_node,

roles_map type MYTABLE,

flag type abap_bool.

uitab = wd_Context->get_Child_Node( `DROPDOWN` ).

CALL METHOD UITAB->BIND_TABLE

EXPORTING

NEW_ITEMS = roles_map

SET_INITIAL_ELEMENTS = ABAP_TRUE

.

I am just giving you the an example.here DROPDOWN is a node with the attributes of the table type MYTABLE.And you can get the node instance from the context.

Post if you need some more clarification

Thanks

Anzy

Award points for useful answers