Using Drop Down by Index in Table UI Element With Web Dynpro ABAP
Using Drop Down by Index in Table UI Element With Web Dynpro 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
Author Bio
Tulasi Palnati is an Enterprise Portal Consultant at Yash Technologies, Hyderabad-India
Table of Contents
Step 1: Create a WebDynpro Component ......................................................................................................... 3 Step 2: Create a Context to hold data ................................................................................................................ 3 Step 4: Create the Layout and Bind the context to UI Elements ........................................................................ 7 Step 5: Create Application and Test it ............................................................................................................... 9 Output: ............................................................................................................................................................ 9 Related Content ................................................................................................................................................ 11 Disclaimer and Liability Notice .......................................................................................................................... 12
C. Create Node as Shown below.. D. Click on Add Attribute from Structure F. Select components from the structure and Click on finish.
I. Context of the view looks as below. J. Select the SFLIGHT and Double click on CARRID_DATA supply function.
LOOP AT lt_carrid INTO ls_sflight-carrid. ls_sflight-key = sy-index. CONDENSE ls_sflight-key. APPEND ls_sflight TO lt_sflight. CLEAR ls_sflight. ENDLOOP. lr_element = node->get_element( sy-tabix ). wd_node = lr_element->get_child_node( 'SFLIGHT' ). wd_node->bind_table( lt_sflight ). ENDLOOP.
Q. Go to Methods tab. Select On_carrid_select method Double click on it. R. Copy the below code and Paste it.
method ONACTIONON_CARRID_SELECT . DATA: lr_element TYPE REF TO if_wd_context_element, lv_index_table TYPE i, lv_index TYPE i, lt_sflight TYPE wd_this->elements_sflight, ls_sflight TYPE wd_this->element_sflight, wd_node TYPE REF TO if_wd_context_node, ls_spfli TYPE wd_this->element_spfli. *** Get row number from which dropdown value was selected lr_element = wdevent->get_context_element( 'CONTEXT_ELEMENT' ). lv_index_table = lr_element->get_index( ). wd_node = wd_context->get_child_node( 'SPFLI' ). wd_node->set_lead_selection_index( index = lv_index_table ). *** Get the index of value within dropdown which is selected wd_node = wd_context->get_child_node( 'SPFLI' ). wd_node->set_lead_selection_index( index = lv_index_table ). lv_index = wdevent->get_int( name = 'INDEX' ). *** Fetch all the dropdown values into an internal table wd_node = wd_context->path_get_node( 'SPFLI.SFLIGHT' ). CALL METHOD wd_node->get_static_attributes_table EXPORTING from = 1 to = 2000 IMPORTING table = lt_sflight. *** Obtain the value selected in the dropdown by the user using the index obtained READ TABLE lt_sflight INTO ls_sflight INDEX lv_index. wd_node->set_attribute( EXPORTING name = 'CARRID' value = ls_sflight-carrid ). SELECT SINGLE carrid connid countryfr cityfrom airpfrom countryto cityto airpto FROM spfli INTO CORRESPONDING FIELDS OF ls_spfli WHERE carrid = ls_sflight-carrid.
*** Fill the fetched values into the corresponding textfields of table wd_node = wd_context->get_child_node( 'SPFLI' ). CALL METHOD wd_node->set_static_attributes EXPORTING index = lv_index_table static_attributes = ls_spfli. endmethod.
Related Content
E-Learning Tutorials-WebDynpro ABAP WebDynpro ABAP in SDN