Skip to Content

Example to use drop down by key and drop down by index.

Objective:  Example to demonstrate drop down by key and drop down by index in webdynpro ABAP .

Assumptions: Audience of this post is expected to have basic knowledge of Webdynpro abap .

Solution:

http://1.bp.blogspot.com/-8t6jLhVEW5c/UV_z6fWOAtI/AAAAAAAABQI/nyvC9iy2Iy4/s1600/18.JPG

Step 1. Create a webdynpro component and applicaition from se80 , ‘ZDROP_DOWN’.

Step 2. Create a context Attribute ‘DRP_KEY’ ty pe string.

            A node ‘DRP_node’ cardinality o..n ,

            With two attributes ‘DRP_INDEX’ type string,

                                           ‘Value’ type string.

Step 3. Create a Two Group UI Elements , with different IDs, Each having one drop down and one textview. Now , in the first drop down Bind the property value with context ‘DRP_KEY’ do demonstrate drop down by key .

And assign the property Bind with context ‘DRP_INDEX’ in the second drop down.

Step 4. Similarly now bind attribute ‘DRP_KEY’ with the Text property of the ‘TEXTVIEW’ ui element.

And bind attribute ‘VALUE’ with the Text property of the ‘TEXTVIEW2’ ui element.

Step 5. Insert the following code in the WD_INIT method of the view.

*  *code to initialize drop down by Key

DATA drp_info       TYPE REF TO if_wd_context_node_info.
DATA drp_value_set  TYPE wdr_context_attr_value.
DATA drp_value_list TYPE wdr_context_attr_value_list.
DATA index TYPE n.
DO 5 TIMES.
index = syindex .
CONCATENATE ‘ Value ‘ index  INTO drp_value_setvalue SEPARATED BY space.
CONCATENATE ‘ Value ‘ index  INTO drp_value_settext SEPARATED BY space.
INSERT drp_value_set INTO TABLE drp_value_list.
ENDDO.

SORT drp_value_list BY value.
DELETE ADJACENT DUPLICATES FROM drp_value_list COMPARING value.
drp_info
= wd_context->get_node_info( ).
drp_info
->set_attribute_value_set(
name
= ‘DRP_KEY’ value_set = drp_value_list ).

*code to initialize drop down by index

DATA lo_nd_drp_node TYPE REF TO if_wd_context_node.

DATA ls_drp_node TYPE wd_this->element_drp_node.
DATA lt_drp_node TYPE wd_this->elements_drp_node.

* navigate from  to  via lead selection
lo_nd_drp_node
= wd_context->get_child_node( name = wd_this->wdctx_drp_node ).

DO 5 TIMES.

index = syindex.
CONCATENATE ‘Value’ index INTO ls_drp_nodevalue SEPARATED BY space.
CONCATENATE ‘Value’ index INTO ls_drp_nodedrp_index SEPARATED BY space.
APPEND ls_drp_node TO lt_drp_node.
ENDDO.

lo_nd_drp_node->bind_table( new_items = lt_drp_node set_initial_elements = abap_false ).

http://2.bp.blogspot.com/-PVKRyw6Sg34/UV_z5c3donI/AAAAAAAABQE/W5FGUvlhycg/s1600/17.JPG

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

Leave a Reply