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.

2

New Language Features in ABAP 7.4

CREATE OBJECT mo_model

EXPORTING

io_logger = lo_logger

io_pers_layer = lo_mock_pers_layer

CREATE OBJECT lo_view.

CREATE OBJECT lo_controller

EXPORTING

io_model = lo_model

io_view = lo_view.

Listing 2.77 Building Up a Complex Object before 7.4

Well-designed OO programs need a lot of small classes that work together in

order to make them more resistant to change—but what a lot of lines of code you

need to create an instance of your appl ication controller! If you will forgive the

pun, with release 7.4 of ABAP you can replace all this with one “monster” line of

code, as shown in Listing 2.78. The CREATE OBJECT statements can be replaced by

the NEW constructor operator each time yo u want to pass in a parameter to an

object’s constructor—and you no longer need the data declarations, because the

type of the newly created object is take n from the definition of the importing

parameter of the constructor.

lo_controller = NEW lcl_controller(

lo_model = NEW zcl_monster_model(

io_logger = NEW zcl_logger( )

io_pers_layer = NEW lcl_mock_pers_layer( ) )

lo_view = NEW lcl_view ( )).

Listing 2.78 Building up a Complex Object in 7.4

This time, the new process knocked out almost two out of three lines of code: the

data declarations and the CREATE OBJECT statements.

2.10 Cross-Program Communication

Imagine that Igor the Hunchback is sittin g in front of the SAP screen, looking at

an ALV report that lists requests for monsters to go out and terrorize villages. Igor

has to select a monster, click the Go icon, and then enter some instructions into

a pop-up box, and then the monster drops off of the unprocessed part of the list.

Meanwhile, in a distant part of the cast le, Baron Frankenstein is using CIC0 to

take calls from customers, like evil landowners in top hats who want to hire monsters

to scare their rebellious villages back into line.

134

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

Saved successfully!

Ooh no, something went wrong!