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.

8

Business Object Processing Framework (BOPF)

between this and the actual action vali dation is a bit blurry. This method is

called twice when an action is processed. First, it’s called just before a validation

is performed to see if an action can be executed. Then, it’s called again just

before the EXECUTE method. Naturally, you get the same set of keys each time,

so only objects that are going to have the action performed on them have an

action validation processed. This method is optional.

왘 EXECUTE

This is the important—that is, not optional—method. It calls the corresponding

action method of your monster model. The signature of the method contains

READ and MODIFY objects for getting and changing any BOPF data, a generic data

object coming in to store any user input parameters, and an error message

object plus a table of failed keys that you can send out (Figure 8.22).

Figure 8.22 Action EXECUTE Method Signature

The actual coding is pretty much the same as the validation and is shown in Listing

8.16. The full code is shown here just to make it clear what’s happening; normally,

you would identify any duplicate code between different classes and

encapsulate it in a utility method.

There are several parts to Listing 8.16. First, you get the data in the header row of

the monster on which the action is to be performed. You use this to get an

instance of the monster model via the factory method of the monster class.

Then, you have to transform the generic data reference object, which is sent to

you by BOPF. This object contains the values of the import parameters you need

to send to the model. Change this to an actual structured variable, and then you

can call the real action method of the model, HOWL_AT_THE_MOON.

328

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

Saved successfully!

Ooh no, something went wrong!