Tuesday, April 10, 2012
Program steps
- Go to Component Controller COMPONENTCONTROLLER.
- Context tab->Create COUNTRY node with cardinality 0..n and attributes(refer to T005T structure).
- Methods tab->Write the code in WDDOINIT to populate data to show countries as list.
- WDDOINIT code
METHOD wddoinit . wd_this->get_listbox_data( ). ENDMETHOD.
METHOD get_listbox_data .
DATA lo_nd_country TYPE REF TO if_wd_context_node.
DATA lt_country TYPE wd_this->elements_country.
* navigate from <CONTEXT> to <COUNTRY> via lead selection
lo_nd_country = wd_context->get_child_node( name = wd_this->wdctx_country ).
SELECT land1 landx
FROM t005t
INTO CORRESPONDING FIELDS OF TABLE lt_country
WHERE spras = sy-langu.
lo_nd_country->bind_table( new_items = lt_country set_initial_elements = abap_true ).
ENDMETHOD.
- GET_SELECTED_RECS code
METHOD get_selected_recs . * "Get selected Elements DATA lo_nd_country TYPE REF TO if_wd_context_node. DATA lt_country TYPE wd_this->elements_country. data: ls_country TYPE wd_this->element_country. data: lt_ctry TYPE wd_this->elements_country. DATA lt_elements TYPE wdr_context_element_set. DATA ls_elements TYPE REF TO if_wd_context_element. "Navigate from <CONTEXT> to <COUNTRY> via lead selection lo_nd_country = wd_context->get_child_node( name = wd_this->wdctx_country ). lt_elements = lo_nd_country->get_selected_elements( ). LOOP AT lt_elements INTO ls_elements. ls_elements->get_static_attributes( IMPORTING static_attributes = ls_country ). APPEND ls_country TO lt_ctry. ENDLOOP. "Display selected Elements DATA lo_nd_dsp_coutries TYPE REF TO if_wd_context_node. DATA lt_dsp_coutries TYPE wd_this->elements_dsp_coutries. * navigate from <CONTEXT> to <DSP_COUTRIES> via lead selection lo_nd_dsp_coutries = wd_context->get_child_node( name = wd_this->wdctx_dsp_coutries ). LOOP AT lt_ctry INTO ls_country. SELECT * FROM t005t APPENDING CORRESPONDING FIELDS OF TABLE lt_dsp_coutries WHERE spras = sy-langu AND land1 = ls_country-land1. ENDLOOP. lo_nd_dsp_coutries->bind_table( new_items = lt_dsp_coutries set_initial_elements = abap_true ). ENDMETHOD.
- Context tab->Map context of Component controller to context of view.
- Layout tab->define UI elements 1). ItemListBox 2). Button and OnAction event 3). Table as shown below.
- Methods tab->call GET_SELECTED_RECS method from ONACTIONDISPLAY_SELECTED event handler method.
METHOD onactiondisplay_selected . DATA lo_componentcontroller TYPE REF TO ig_componentcontroller . lo_componentcontroller = wd_this->get_componentcontroller_ctr( ). lo_componentcontroller->get_selected_recs( ). ENDMETHOD.
- Run application.
Followers
Popular Posts
- ABAP - ALV Report example with steps
- ABAP - Step by step tutorial on Smart Forms - Template Node
- ABAP - Sending email with pdf attachment
- SAP Adobe Form - Steps to create simple ADOBE Form and calling it from ABAP Program
- SAP ABAP - CL_ABAP_CHAR_UTILITIES class usage
- ABAP - Multiple value selection from F4 help for SELECT-OPTIONS
- Execute ABAP Report using SUBMIT statement
- ABAP - Select all or Deselect all in ALV or Check box handling in ALV
- Web Dynpro ABAP ALV - ON_CLICK event
- ABAP - Dynamic WHERE clause
0 comments:
Post a Comment
Your useful comments, suggestions are appreciated.Your comments are moderated.