how to populate values in dropdownbykey in webdynpro
2017-12-01 16:01
507 查看
There are 2 types of dropdown ui elemts:
1. For DropDownByIndex UI element we need to bind the text property to an attribute within a context node, which contains several elements (cardinality = 0..n). The number of elements defines the possible entries in the list. In the WDDOINIT method we can prepare
an internal table with the values and bind it to the node and the lead selection defines the selected element.
For example if u have defined a node 'TEXT' with cardinality '0..n' with attribute TEXT. Bind the text property of DropDownbyIndex UI element to attribute Text of context node Text.
In the WDDOINIT method you can prepare an internal table with the values and bind it to the node and the lead selection defines the selected element.
The below code sample may help.
Copy Code
method WDDOINIT .
data:
node_text type ref to if_wd_context_node,
stru_text type if_componentcontroller=>element_text,
tab_text type if_componentcontroller=>elements_text .
node_text = wd_context->get_child_node( name = if_componentcontroller=>wdctx_text ).
* Set/fill your values
stru_text-text = 'Value1'.
append stru_text to tab_text.
stru_text-text = 'Value2'.
append stru_text to tab_text.
* set values to the node
call method node_ddi_also_text->bind_table
exporting
new_items = tab_text.
endmethod.
2. For DropDownByKey UI element bind the SelectedKey property to an attribute within a context node. Then you must provide the fixed values (table with key value combination) in a different way and store them in the node info. We can use the elements get_attribute
method to get the attribute value which user has selected.
For this we need to use the interface IF_WD_CONTEXT_NODE which has a method GET_NODE_INFO, which returns meta information on the respective node. This information is of type IF_WD_CONTEXT_NODE_INFO.
Kindly refer the following code:
Copy Code
method WDDOINIT .
data: NODE_INFO type ref to IF_WD_CONTEXT_NODE_INFO,
NODE type ref to IF_WD_CONTEXT_NODE.
NODE = WD_CONTEXT->GET_CHILD_NODE( 'NODE1' ).
NODE_INFO = NODE->GET_NODE_INFO( ).
* To be able to store the fixed values for the attribute in the node info, two
*additional variables are necessary:
data: LT_VALUESET type WDR_CONTEXT_ATTR_VALUE_LIST ,
L_VALUE type WDR_CONTEXT_ATTR_VALUE.
*WDR_CONTEXT_ATTR_VALUE is a data type defined in the DDIC. It contains *two components KEY and VALUE, both of type STRING.
*WDR_CONTEXT_ATTR_VALUE_LIST is a table type stored in the DDIC, whose *rows are of type WDR_CONTEXT_ATTR_VALUE.
*The two variables created in the source text example are used to accept the value *pairs that will later be passed to the node info.
L_VALUE-VALUE = 'V1'.
L_VALUE-TEXT = 'yesterday'.
INSERT L_VALUE into table LT_VALUESET.
L_VALUE-VALUE = 'V2'.
L_VALUE-TEXT = 'today'.
INSERT L_VALUE into table LT_VALUESET.
L_VALUE-VALUE = 'V3'.
L_VALUE-TEXT = 'tomorrow'.
INSERT L_VALUE into table LT_VALUESET.
NODE_INFO->SET_ATTRIBUTE_VALUE_SET (
NAME = 'ATTRIBUTE1'
VALUE_SET = LT_VALUESET ).
endmethod.
1. For DropDownByIndex UI element we need to bind the text property to an attribute within a context node, which contains several elements (cardinality = 0..n). The number of elements defines the possible entries in the list. In the WDDOINIT method we can prepare
an internal table with the values and bind it to the node and the lead selection defines the selected element.
For example if u have defined a node 'TEXT' with cardinality '0..n' with attribute TEXT. Bind the text property of DropDownbyIndex UI element to attribute Text of context node Text.
In the WDDOINIT method you can prepare an internal table with the values and bind it to the node and the lead selection defines the selected element.
The below code sample may help.
Copy Code
method WDDOINIT .
data:
node_text type ref to if_wd_context_node,
stru_text type if_componentcontroller=>element_text,
tab_text type if_componentcontroller=>elements_text .
node_text = wd_context->get_child_node( name = if_componentcontroller=>wdctx_text ).
* Set/fill your values
stru_text-text = 'Value1'.
append stru_text to tab_text.
stru_text-text = 'Value2'.
append stru_text to tab_text.
* set values to the node
call method node_ddi_also_text->bind_table
exporting
new_items = tab_text.
endmethod.
2. For DropDownByKey UI element bind the SelectedKey property to an attribute within a context node. Then you must provide the fixed values (table with key value combination) in a different way and store them in the node info. We can use the elements get_attribute
method to get the attribute value which user has selected.
For this we need to use the interface IF_WD_CONTEXT_NODE which has a method GET_NODE_INFO, which returns meta information on the respective node. This information is of type IF_WD_CONTEXT_NODE_INFO.
Kindly refer the following code:
Copy Code
method WDDOINIT .
data: NODE_INFO type ref to IF_WD_CONTEXT_NODE_INFO,
NODE type ref to IF_WD_CONTEXT_NODE.
NODE = WD_CONTEXT->GET_CHILD_NODE( 'NODE1' ).
NODE_INFO = NODE->GET_NODE_INFO( ).
* To be able to store the fixed values for the attribute in the node info, two
*additional variables are necessary:
data: LT_VALUESET type WDR_CONTEXT_ATTR_VALUE_LIST ,
L_VALUE type WDR_CONTEXT_ATTR_VALUE.
*WDR_CONTEXT_ATTR_VALUE is a data type defined in the DDIC. It contains *two components KEY and VALUE, both of type STRING.
*WDR_CONTEXT_ATTR_VALUE_LIST is a table type stored in the DDIC, whose *rows are of type WDR_CONTEXT_ATTR_VALUE.
*The two variables created in the source text example are used to accept the value *pairs that will later be passed to the node info.
L_VALUE-VALUE = 'V1'.
L_VALUE-TEXT = 'yesterday'.
INSERT L_VALUE into table LT_VALUESET.
L_VALUE-VALUE = 'V2'.
L_VALUE-TEXT = 'today'.
INSERT L_VALUE into table LT_VALUESET.
L_VALUE-VALUE = 'V3'.
L_VALUE-TEXT = 'tomorrow'.
INSERT L_VALUE into table LT_VALUESET.
NODE_INFO->SET_ATTRIBUTE_VALUE_SET (
NAME = 'ATTRIBUTE1'
VALUE_SET = LT_VALUESET ).
endmethod.
相关文章推荐
- Dropdown by index in ALV using in Web Dynpro
- webdynpro dropdownbykey的使用
- Radio button group by Key in webdynpro ABAP
- How to monitor Web server performance by using counter logs in System Monitor in IIS
- Using drop down by key in webdynpro ABAP
- 个人收藏 Dropdown by index in ALV using in Web Dynpro
- How to display column values in a single cell in Web Intelligence using Oracle database ?
- How to sort a Map<Key, Value> on the values in Java?
- HOW TO: Upload a File to a Web Server in ASP.NET by Using Visual Basic .NET
- How to Reference and Use JSTL in your Web Application
- How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings
- How To Use Putty with an SSH Private Key Generated by OpenSSH
- How to get the content of the 'identity' section in web.config
- How to use Security Policies in WebLogic SCA Web Service Binding
- [Solution]How to create Project Web App in SharePoint
- How to debug Web Services or .Net Remoting Components hosted in IIS in Windows 2003 Server
- How to save content/text of a web page by forcing save-as option
- How to determine who is logged on to a database by using Microsoft Jet UserRoster in Access 2000
- How to synchronize access to a shared resource in a multithreading environment by using Visual C#
- How to crawl a quarter billion webpages in 40 hours