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.

10

ALV SALV Reporting Framework

report. You might have a report that’s a list of monsters, and you can select a

checkbox by a particular monster, and then click an icon at the top of the screen,

which displays a map showing the monster’ s location in real time. In a slightly

more realistic example, you might have a list of customers whose orders are going

to be delivered late, and you select a customer, and then click a button, which

triggers an outgoing phone call to the phone number stored in SAP ERP so that

you can tell them the bad news. Neither of those examples would have been feasible

10 years ago, which shows how far technology has come.

Anyway, you want to be able to pass in a list of these extra user commands into

your report object, and have extra buttons appear at the top of the screen, and

have extra options on the context menu the users get when they select a record

and right-click. A table of the structure STB_BUTTON is ideal for this purpose,

because it has fields for the name of the new command, what it should look like

(icon, button, etc.), and text description fields to tell the user what the button

does: a short description that appears next to the button and a longer description

that appears via hover text.

In a good OO program, this list comes from the application model, which says to

the controller something like, “Hello, here’s a list of commands I can respond to.

I’ll give you the descriptions and a rough guide to how they should look, but I’ll

leave the actual details to you.” The controller passes the instructions to the view

with a similar comment. This way, wh en a new and better view technology

comes along, the controller can cast aside the old view and run off with the new

younger one but still give it the exact same command list.

The actual table is passed in changing parameter CT_DATA_TABLE typed as a

generic table, due to the fact that the structure of the table to be displayed is different

for every report. This example uses a changing parameter for the technical

reason that some technologies want this table as a changing parameter and others

wants it as a pure importing parameter. A changing parameter is the lowest common

denominator; you can have a changing parameter and not change it, but you

can’t have an importing parameter and then try to change it in an OO method.

In order to code the INITIALIZE method, you have to split up the creation of the

view object and the initialization, because you create the view object, then link it

into the MVC framework, and only at a later date when you have the finished

report data from the model do you actually create the underlying report object.

418

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

Saved successfully!

Ooh no, something went wrong!