14.01.2020 Views

ABAP_to_the_Future

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

12

Web Dynpro ABAP and Floorplan Manager

be. I don’t mind admitting that I’m a purist, and we’re about to start doing some

coding in the view here. I have no problem at all with the view having code, as

long as that code relates solely to view-specific tasks. The view’s job is to send any

user input somewhere else for processing , to get the results, and then to show

those results on the screen, making them look as nice as possible. If the code in

the view is restricted to those tasks, then you can have 20 billion lines of code if

you want to, and my delicate sensibilities will not be offended.

So what does this coding entail? First, you’ll learn how to make sure that the controller

knows about the model so that the view can delegate non-view-type tasks.

Then you’ll learn about the coding needed in the view in order to bring up the list

of monsters once the user has made some selections. Finally, you’ll learn about

the coding needed once the user selects a specific monster in order to bring up

the view showing the details of that monster.

Linking the Controller to the Model

As there is going to be some coding inside the views, you will see that whenever

any non-view-related tasks are to be performed, they will be delegated to the controller,

which will often delegate that task to the model. Thus, you need the controller

to know about the model. Go to the component controller Attribute tab,

and declare MO_MONSTER_MODEL as TYPE REF TO ZCL_MONSTER_MODEL.

Then, in the WDDOINIT method of the controller, add the following statement:

CREATE OBJECT wd_this->mo_monster_model.

Selecting Monster Records

You should understand each block of code that needs to be created in the order in

which the user interacts with the applicat ion. On the initial screen, there is a

blank set of selection options and a blank grid. The user says he wants a list of all

monsters named Fred and presses the Find Monsters button.

When you defined that button, you created an action called FIND_MONSTERS. If

you navigate to the Methods tab of the V_SELECT_OPTIONS view, then you can see

that there is an automatica lly generated method called ONACTIONFIND_MONSTERS

for that action sitting there. If you double -click that method, then you’ll enter a

screen that looks a bit like Transaction SE24 (but which is subtly different), from

which you can do some coding.

536

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

Saved successfully!

Ooh no, something went wrong!