Fetch Row Details On Enter Action With Lead Selection in Webdynpro

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 14

Scenario: Fetch Row Details on Enter Action with Lead Selection.

Step1: Create a Webdynpro Component, go to Context and Create a Node as shown.

Note: Cardinality should be o:n and Selection should also be o:n as we are intending to select multiple rows .

Step2: Design layout calling the node MAKT as a table through wizard.

Select Input Field as we need Input Enabled Table

Step 3: Make sure you have changed the Table UI Element properties as shown.

Step 4: Assign On Enter for the Column MATNR

Step 5:

Double Click on ONENTER and Provide the Following Code.

method ONACTIONONENTER . DATA lo_nd_makt TYPE REF TO if_wd_context_node. DATA lo_el_makt TYPE REF TO if_wd_context_element. DATA lt_makt TYPE wd_this->elements_makt. DATA lv_matnr TYPE wd_this->element_makt-matnr. DATA lv_spras TYPE wd_this->element_makt-spras. DATA lv_maktg TYPE wd_this->element_makt-maktg. DATA lv_maktx TYPE wd_this->element_makt-maktx. lo_nd_makt = wd_context->get_child_node( name = wd_this->wdctx_makt ). IF lo_nd_makt IS INITIAL. ENDIF. lo_el_makt = lo_nd_makt->get_element( ). IF lo_el_makt IS INITIAL. ENDIF. lo_el_makt->get_attribute( EXPORTING name = `MATNR` IMPORTING value = lv_matnr ). lo_el_makt = lo_nd_makt->get_element( ). select SINGLE spras maktg maktx INTO (lv_spras,lv_maktg,lv_maktx) from

makt where matnr if sy-subrc = 0. lo_el_makt->set_attribute( name = `SPRAS` value = lv_spras ). lo_el_makt = lo_nd_makt->get_element( lo_el_makt->set_attribute( name = `MAKTG` value = lv_MAKTG ). lo_el_makt = lo_nd_makt->get_element( lo_el_makt->set_attribute( name = `MAKTX` value = lv_maktx ). else. * get message manager DATA lo_api_controller TYPE REF DATA lo_message_manager TYPE REF

= lv_matnr.

).

).

TO if_wd_controller. TO if_wd_message_manager.

lo_api_controller ?= wd_this->wd_get_api( ). CALL METHOD lo_api_controller->get_message_manager RECEIVING message_manager = lo_message_manager. CALL METHOD lo_message_manager->report_error_message EXPORTING message_text = 'No Record Exists for the Given Material'. endif. endmethod.

Step 6: As we are suppose to make the table Input Enabled, provide the code for initializing the table in method WDDOINIT.

method WDDOINIT . Types : Begin of ty_makt, MATNR type makt-matnr, spras type makt-spras, ERNAM type makt-maktg, LAEDA type makt-maktx, end of ty_makt. Data : lt_material type standard table of ty_makt, wa_makt type ty_makt. Do 10 times. Append wa_makt to lt_material. enddo. DATA lo_nd_material TYPE REF TO if_wd_context_node. lo_nd_material = wd_context->get_child_node( name = wd_this->wdctx_makt ). lo_nd_material>bind_table( new_items = lt_material set_initial_elements = abap_true ). endmethod.

Step 7: Bind your view to window.

10

11

Step 8: Create an Application and Test.

12

Step 9: Provide the Material number using F4.

Hit Enter on the material number or click on the row selecting it as shown pointed.

As a result you will get the corresponding details of the Material Number entered. 13

Note: You can give the next row also, but make sure that row is selected (Highlighted in Yellow Color).

14

You might also like