View
354
Download
0
Category
Tags:
Preview:
DESCRIPTION
In our day to day programming need one may need to display the details of the row providing primary key and by hitting enter key they may need to populate its corresponding details.I have formed a scenario of the above mentioned business need.
Citation preview
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 .
1
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( ).
8
select SINGLE spras maktg maktx INTO (lv_spras,lv_maktg,lv_maktx) from makt where matnr = lv_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 TO if_wd_controller. DATA lo_message_manager TYPE REF 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.
9
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
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
Recommended