Using Drop Down By Index in Table UI Element in WebDynpro ABAP

Applies to:
Enterprise portal, ECC 6.0, Web Dynpro ABAP. For more information, visit the Web Dynpro ABAP homepage.

Summary
This article would help ABAP developers, who are faced with a scenario of having a DropDownByIndex within the Table UI Element in their Web Dynpro Component. Author: Tulasi Palnati

Company: Yash Technologies Created on: 15 September 2009

Author Bio
Tulasi Palnati is an Enterprise Portal Consultant at Yash Technologies, Hyderabad-India

SAP COMMUNITY NETWORK © 2009 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 1

..................com 2 .Using Drop Down By Index in Table UI Element in WebDynpro ABAP Table of Contents Step 1: Create a WebDynpro Component ......................................................................................sdn.....................................boc...com | BPX ......................................sap...............................................sap..............................................bpx...........................................................................................................com | BOC .................................... 9 Related Content ....................................................sap. 11 Disclaimer and Liability Notice ............... 12 SAP COMMUNITY NETWORK © 2009 SAP AG SDN ......... 3 Step 2: Create a Context to hold data .................................................................................................... 7 Step 5: Create Application and Test it ....................................................................... 3 Step 4: Create the Layout and Bind the context to UI Elements ............................................................................................................................ 9 Output: .........................................

com | BOC .com | BPX .sap. Select components from the structure and Click on finish.bpx. Double click on View.sap.sap. Click on Add Attribute from Structure F.sdn. Create Node as Shown below. Go to Context Tab.com 3 .Using Drop Down By Index in Table UI Element in WebDynpro ABAP Step 1: Create a WebDynpro Component A. D. Create a new WebDynpro component by the name ZWD_DROPDOWN_TABLE. Step 2: Create a Context to hold data B. SAP COMMUNITY NETWORK © 2009 SAP AG SDN .boc.. C.

sap.com 4 . Create another node under SPFLI node as below.bpx.com | BPX .sdn.sap.sap. SAP COMMUNITY NETWORK © 2009 SAP AG SDN .Using Drop Down By Index in Table UI Element in WebDynpro ABAP G.boc.com | BOC .

Select the SFLIGHT and Double click on CARRID_DATA supply function. Create two attributes under the Node SFLIGHT as below.sdn. J. SAP COMMUNITY NETWORK © 2009 SAP AG SDN .sap.Using Drop Down By Index in Table UI Element in WebDynpro ABAP H.com | BOC . I.boc.com 5 .sap.bpx. Context of the view looks as below.sap.com | BPX .

ENDDO. lt_sflight TYPE wd_this->elements_sflight. DATA: lt_carrid TYPE TABLE OF s_carr_id.com | BPX . APPEND ls_spfli TO lt_spfli.com | BOC .sdn. ls_sflight TYPE wd_this->element_sflight.sap.bpx.Using Drop Down By Index in Table UI Element in WebDynpro ABAP Step 3: Code for Supply Function. lr_element TYPE REF TO if_wd_context_element.sap. Copy the below code in the method CARRID_DATA. SAP COMMUNITY NETWORK © 2009 SAP AG SDN . node->bind_table( new_items = lt_spfli set_initial_elements = abap_true ). lt_spfli TYPE wd_this->elements_spfli. ls_spfli TYPE wd_this->element_spfli. wd_node TYPE REF TO if_wd_context_node.com 6 . SELECT DISTINCT carrid UP TO 20 ROWS FROM sflight INTO TABLE lt_carrid. *** This would create 20 blank rows in the table with only the dropdown filled with CARRID values DO 20 TIMES. LOOP AT lt_spfli INTO ls_spfli.boc. K.sap.

Using Drop Down By Index in Table UI Element in WebDynpro ABAP LOOP AT lt_carrid INTO ls_sflight-carrid. Double Click on view layout tab.sap.SFLIGHT. CONDENSE ls_sflight-key.SPFLI.com | BOC . Create one action On_CARRID_SELECT. wd_node = lr_element->get_child_node( 'SFLIGHT' ). Bind the texts Property of Carrid DropdownByIndex with MAIN. Click on ROOTUIELEMENTCONTAINER create element TABLE.sdn. ls_sflight-key = sy-index. CLEAR ls_sflight. wd_node->bind_table( lt_sflight ). N.CARRID P. ENDLOOP.boc. SAP COMMUNITY NETWORK © 2009 SAP AG SDN . ENDLOOP. M.sap.com | BPX . APPEND ls_sflight TO lt_sflight. 0.com 7 .bpx. lr_element = node->get_element( sy-tabix ).sap. Step 4: Create the Layout and Bind the context to UI Elements L. Bind SPFLI node elements to the table as below.

SFLIGHT' ).sap. Copy the below code and Paste it.sap. *** Obtain the value selected in the dropdown by the user using the index obtained READ TABLE lt_sflight INTO ls_sflight INDEX lv_index. Go to Methods tab. lv_index_table TYPE i. *** Fetch all the dropdown values into an internal table wd_node = wd_context->path_get_node( 'SPFLI. wd_node->set_lead_selection_index( index = lv_index_table ).com | BPX . wd_node TYPE REF TO if_wd_context_node. DATA: lr_element TYPE REF TO if_wd_context_element. lv_index = wdevent->get_int( name = 'INDEX' ). *** Get the index of value within dropdown which is selected wd_node = wd_context->get_child_node( 'SPFLI' ).bpx. method ONACTIONON_CARRID_SELECT . lv_index_table = lr_element->get_index( ). lv_index TYPE i. lt_sflight TYPE wd_this->elements_sflight.Using Drop Down By Index in Table UI Element in WebDynpro ABAP Q. ls_sflight TYPE wd_this->element_sflight. wd_node->set_attribute( EXPORTING name = 'CARRID' value = ls_sflight-carrid ). *** Get row number from which dropdown value was selected lr_element = wdevent->get_context_element( 'CONTEXT_ELEMENT' ).sap. Select On_carrid_select method Double click on it. SELECT SINGLE carrid connid countryfr cityfrom airpfrom countryto cityto airpto FROM spfli INTO CORRESPONDING FIELDS OF ls_spfli WHERE carrid = ls_sflight-carrid. ls_spfli TYPE wd_this->element_spfli. wd_node->set_lead_selection_index( index = lv_index_table ).com 8 .boc. wd_node = wd_context->get_child_node( 'SPFLI' ). SAP COMMUNITY NETWORK © 2009 SAP AG SDN . CALL METHOD wd_node->get_static_attributes_table EXPORTING from = 1 to = 2000 IMPORTING table = lt_sflight.com | BOC . R.sdn.

Now Create a WebDynpro Application and save and activate all. CALL METHOD wd_node->set_static_attributes EXPORTING index = lv_index_table static_attributes = ls_spfli.bpx.Using Drop Down By Index in Table UI Element in WebDynpro ABAP *** Fill the fetched values into the corresponding textfields of table wd_node = wd_context->get_child_node( 'SPFLI' ).com 9 .sdn. endmethod. Output: SAP COMMUNITY NETWORK © 2009 SAP AG SDN .com | BOC .boc. Step 5: Create Application and Test it S.com | BPX .sap.sap.sap.

com | BPX .sdn.com | BOC .boc.bpx.sap.sap.sap.com 10 .Using Drop Down By Index in Table UI Element in WebDynpro ABAP SAP COMMUNITY NETWORK © 2009 SAP AG SDN .

com | BOC .sap.com | BPX .sap.bpx.Using Drop Down By Index in Table UI Element in WebDynpro ABAP Related Content E-Learning Tutorials-WebDynpro ABAP WebDynpro ABAP in SDN SAP COMMUNITY NETWORK © 2009 SAP AG SDN .com 11 .sdn.sap.boc.

boc. Changes made based on this information are not supported and can be overwritten during an upgrade.com | BOC . code or methods suggested in this document.sap.Using Drop Down By Index in Table UI Element in WebDynpro ABAP Disclaimer and Liability Notice This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP. SAP will not be held liable for any damages caused by using or misusing the information. SAP COMMUNITY NETWORK © 2009 SAP AG SDN . SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample. and anyone using these methods does so at his/her own risk. SAP responsible or liable with respect to the content of this document.sap.com | BPX . or seek to hold. including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP.bpx. You agree that you will not hold.sdn.com 12 .sap.

Sign up to vote on this title
UsefulNot useful