Top Banner
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
15

Fetch Row Details on Enter Action With Lead Selection in Webdynpro

Dec 02, 2015

Download

Documents

Amrutha Prabhu

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.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Fetch Row Details on Enter Action With Lead Selection in Webdynpro

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

Page 2: Fetch Row Details on Enter Action With Lead Selection in Webdynpro

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

2

Page 3: Fetch Row Details on Enter Action With Lead Selection in Webdynpro

Select Input Field as we need Input Enabled Table

3

Page 4: Fetch Row Details on Enter Action With Lead Selection in Webdynpro

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

4

Page 5: Fetch Row Details on Enter Action With Lead Selection in Webdynpro

5

Page 6: Fetch Row Details on Enter Action With Lead Selection in Webdynpro

Step 4: Assign On Enter for the Column MATNR

6

Page 7: Fetch Row Details on Enter Action With Lead Selection in Webdynpro

Step 5:

Double Click on ONENTER and Provide the Following Code.

7

Page 8: Fetch Row Details on Enter Action With Lead Selection in Webdynpro

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

Page 9: Fetch Row Details on Enter Action With Lead Selection in Webdynpro

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

Page 10: Fetch Row Details on Enter Action With Lead Selection in Webdynpro

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

Page 11: Fetch Row Details on Enter Action With Lead Selection in Webdynpro

11

Page 12: Fetch Row Details on Enter Action With Lead Selection in Webdynpro

Step 8: Create an Application and Test.

12

Page 13: Fetch Row Details on Enter Action With Lead Selection in Webdynpro

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

Page 14: Fetch Row Details on Enter Action With Lead Selection in Webdynpro

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

14