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.

13

SAPUI5

Figure 13.27 Monster View Output

In order to end up with Figure 13.27, you have to do some coding. Every view

needs a controller, so the very first thing that happens in your view file is to say

what the name of the controller file is. The controller isgoing to have all the code;

all you’re doing in the view is laying ou t the screen and sometimes saying that a

screen element will respond to being cl icked. The controller will worry about

what to do if a user does click such a field or button.

In Listing 13.6, you set the header leve l information for the view—not only the

name of the controller but also some SAPUI5 libraries that it will need to run,

such as SAP.M. This is similar to having INCLUDE files in old-fashioned ABAP programs

full of reusable subroutines.

<core:View xmlns:core="sap.ui.core"

xmlns:mvc="sap.ui.core.mvc"

xmlns="sap.m"

controllerName="monster.myView"

xmlns:html="http://www.w3.org/1999/xhtml">

Listing 13.6 A View Defining the Name of Its Controller

All the code in Listing 13.6 was automati cally generated for you at the time the

view file was created (which was when you clicked the Finish button in Figure

13.25), so now you can move on to defining your own code to define what your

monster screen looks like. All good screens need a title at the top; for this one, the

title will be Search for Monsters . Also, put a button next to the title, for no

good reason other than to show that you can put buttons in the title bar, just like

the icons at the top of an ALV screen. Listing 13.7 shows the code for adding the

title, and Figure 13.28 shows the result.

598

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

Saved successfully!

Ooh no, something went wrong!