on 03-03-2009 4:11 AM
Hi,
Is it better to use Drop down by Index or Drop down by Key if I want to use this drop down as a field in a table????
Also can anybody guide me with sample code as to how to use drop-down in the table.
Thanks and Regards,
Kanakaraj V A
hi,
-> First add a table column to your table.
-> Insert Drop by index / drop down by key into the table column.
-> Bind this table column to a node.
-> Populate the values into the Drop Down using the following code.
For Drop Down by Index :
method WDDOINIT .
data : it_table type STANDARD TABLE OF sflight.
DATA lo_nd_cn_drpindex TYPE REF TO if_wd_context_node.
DATA lo_el_cn_drpindex TYPE REF TO if_wd_context_element.
DATA ls_cn_drpindex TYPE wd_this->element_cn_drpindex.
navigate from <CONTEXT> to <CN_DRPINDEX> via lead selection
lo_nd_cn_drpindex = wd_context->get_child_node( name = wd_this->wdctx_cn_drpindex ).
select carrid from sflight into CORRESPONDING FIELDS OF TABLE it_table.
lo_nd_cn_drpindex->bind_table( it_table ).
endmethod.
In the above code, drop down by index values are populated in the WD Do Init.
-
For Drop Down by Key Use the following Code :
method WDDOINIT .
DATA : node_info TYPE REF TO if_wd_context_node_info,
value1 TYPE wdy_key_value,
set TYPE wdy_key_value_table,
k1 type string value 'M',
v1 type string value 'MAGO',
k2 type string value 'S',
v2 type string value 'Saurav'.
*
value1-key = k1.
value1-value = v1.
APPEND value1 to set.
value1-key = k2.
value1-value = v2.
APPEND value1 to set.
node_info = wd_context->get_node_info( ).
node_info = node_info->get_child_node('FOR_DROP').
node_info->set_attribute_value_set( name = 'DROP_KEY' value_set = set ).
endmethod.
I hope this would help you.
Thanx.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Kanakaraj,
To make the changes in the database you need to trigger some action to do the same.
In the event handler of the same action, just read the node using get_static_attributes_table method and after getting the values in an internal table use the mdify statement:
Modify table <database table name > from <internal table>.
I hope it helps.
Regards
Arjun
hi,
If you want to make some kind of changes in the table dynamically and reflect those changes in the database table then
-> Make the changes in the table.
-> Add a button UI element after you are done with the changes.
-> Now in the OnAction of button, Read the node which is binded to the table.
-> Now modify the database table uing simple ABAP query.
Look out for Arjun' s response.
Thanx.
Hi Kankaraj,
As per your asking that Is it better to use Drop down by Index or Drop down by Key. That's all depend on the scenario.
1. if the values are less to display and defined in the value range of the domain that you have defined for your attribute, then you can use drop down by index directly.
2. If the values are to display in a drop down box from a internal table or based on a select statement that its to use a drop down by key. Its easy to manipulate.
For using the drop down list in a table, you have to do the following things.
1. create a node that u want to display in a table
2. set the cardinality to 0...n.
3. create a table UI element in your view.
4. right click on the table element and click create binding.
5. then map the node with the table and in the cell editor select the ui element for the particular column you want to show( here u can select the dropdownbykey).
6. After this the drop down by key element will be avilable in the table UI element.
To fill the values in the dropdownby key, you have to do like this.
You have to set the values for that attribute to whom you have made the column as drop down by key.
Code :
Data declaration for the payment table node info
DATA : lo_nd_payment_table TYPE REF TO if_wd_context_node,
lo_el_payment_table TYPE REF TO if_wd_context_element,
lr_nodeinfo TYPE REF TO if_wd_context_node_info,
ls_payment_table TYPE wd_this->element_payment_table.
Data declaration for Internal table/workarea
DATA : ls_value_set TYPE wdy_key_value,
lt_value_set TYPE wdy_key_value_table
navigate from <CONTEXT> to <PAYMENT_TABLE> via lead selection
lo_nd_payment_table = wd_context->get_child_node( name = wd_this->wdctx_payment_table ).
lr_nodeinfo = lo_nd_payment_table->get_node_info( ).
get element via lead selection
lo_el_payment_table = lo_nd_payment_table->get_element( ).
IF im_medium = '0001' OR im_medium = '0003'. "If Medium is Internal Transfer/EFT then proceed
getting the disbursement description
CALL FUNCTION '/DMPUI/DB_DISBURSEMENT_INFO'
EXPORTING
iv_prodext = WD_THIS->mst_prod_ext
TABLES
ex_disbursmentdata = lt_description.
REFRESH lt_value_set.
IF lt_description[] IS NOT INITIAL.
LOOP AT lt_description INTO ls_description.
ls_value_set-key = ls_description-disburs_type.
ls_value_set-value = ls_description-description.
Inserting the value to a internal table*
INSERT ls_value_set INTO TABLE lt_value_set.
CLEAR ls_value_set.
ENDLOOP.
Setting the attributes for the value set
lr_nodeinfo->set_attribute_value_set(
EXPORTING
name = `DISBURSEMENT_TYPE`
value_set = lt_value_set ).
ENDIF.
Hopes this will helps you.
Regard
Manoj Kumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.