cancel
Showing results for 
Search instead for 
Did you mean: 

Drop down list in Table

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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.

Former Member
0 Kudos

Hi Saurav,

Thanks for the code. If i make some change in the table then it should reflect the table in the database. How can I track that?

arjun_thakur
Active Contributor
0 Kudos

Hi Kanakaraj,

You can trigger some kind of action to track the changes in table. Either you can put a UI element in the table to do so or you can trigger the same with On_lead_select method.

Regards

Arjun

Former Member
0 Kudos

hi,

Can you elaborate your Question to some extent ?

Which table you are talking about ?

Thanx.

Former Member
0 Kudos

Hi,

If i do some changes in the table UI element dynamically it should change the corresponding content in the table in the database.

Thanks,

Kanakaraj V A

arjun_thakur
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

Hi,

I hope i got how to do it now.

Thanks a lot Saurav and Arjun.

Regards,

Kanakaraj V A

Answers (1)

Answers (1)

former_member402443
Contributor
0 Kudos

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