14.01.2020 Views

ABAP_to_the_Future

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

12

Web Dynpro ABAP and Floorplan Manager

changed will be unaware of what you have changed and thus not dependent on it

in any way (and so they cannot break).

The end result of all this is that in Listing 12.1 you saw that the view was getting

the data by calling a method of its controller—so you need to go to the COMPO-

NENTCONTROLLER node and create such a method, with the exact same parameters

as the corresponding method in ZCL_MONSTER_MODEL. Then add the coding as

shown. The view only knows about the controller and no other layers.

In Listing 12.2, you see the listing of that method in the controller, which is not

very exciting; all it does is make the same request of a method in the model with

the exact same name and signature.

METHOD retrieve_headers_by_attribute .

wd_this->mo_monster_model->retrieve_headers_by_attribute(

EXPORTING

it_selections = it_selections

IMPORTING

et_monster_headers = et_monster_headers ).

ENDMETHOD.

Listing 12.2 Controller Method to Retrieve Monster Header Data

This leads to the stage in which the user can enter a monster name such as Fred

and get an ALV grid of monster header records. Now, you need to allow the user

to drill down into a single monster record.

Navigating to the Single Record View

Earlier, when you created a button to show the selected monster, you also created

a corresponding action. A method is automatically generated for you to handle

that action, so go to the V_HEADER_GRID view and fill in the code for the ONACTION-

SHOW_MONSTER method. The code for this is shown in Listing 12.3.

METHOD onactionshow_monster .

* Find the node where the monster header table lives

DATA lo_node_monster_header_table TYPE REF TO if_wd_context_node.

lo_node_monster_header_table = wd_context->get_child_node(

name = wd_this->wdctx_monster_header_table ).

* Get all the selected elements (lines).In fact there is only one

* but as in some applications the user can select more than one

542

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!