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.

8

Business Object Processing Framework (BOPF)

Just like the locking mechanism, authority checks are a simple thing to create and

code for each new business object, but th ey are a manual step nonetheless, and

the idea of BOPF is to remove as many manual steps as possible.

8.2.5 Setting Display Text Using Determinations

It’s likely that many times in your pr ogramming life you have created some sort

of interactive application with a mixtur e of fields retrieved from one or more

database tables directly, and some associated fields where you have either got the

value by looking it up from other database tables (e.g., text fields for the name of

a sales organization) or calculated the value based on some sort of business logic

(e.g., subtracting the time in a database field from the current time). You do this

in ALV type reports; you do this in DYNPRO-type reports; some would say that

this is the staple diet of an SAP programmer, even if we’d all secretly always like

to be doing cutting-edge-type things. In the world of BOPF, naturally you need to

do this as well. This time, the process of setting display text or filling other

derived fields is achieved via determinations.

You’ve already seen that when creating a BOPF object you make a distinction

between the fields that come out of the database (a persistent structure that provides

the values to do the determining) and the fields that you get at runtime (the

transient structure in which the fields get determined). This just provides a home

for something you’ve always done but now can do in a consistent way.

You’ll now learn how to fill some monster-based text fields based on database values

in the monster header table by mean s of creating a determination. Specifically,

you’re going to take the monster’s hat size, which is stored in the database,

and derive a text description, such as “really big hat.” You’ll also take the monster’s

sanity and turn it into a description such as “very mad.”

In this example, there are two fields in your transien t structure that need to be

filled based on the values retrieved from the database. The business logic is nice

and complicated, as is almost always the casein real life. To set this up, go to your

header (root) node (which contains th e database structure), and right-click to

access the context menu. Choose Create Determination.

Figure 8.12 shows the wizard that pops upwhen you’re creating a determination.

The screen asks you to name a class that will be used to house the logic to fill in

the text fields; note that the class name the system proposes is based on the name

you gave to the determination, so don’t make that name generic (i.e., in this

example, it has to mention monsters).

306

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

Saved successfully!

Ooh no, something went wrong!