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)

In this method, you’re not interested in what has changed but rather in the actual

current field values. Although the CHECK_DELTA method is called only when the

record is changed, the CHECK method is called on the initial load of the record and

when the record is changed. If the CHECK_DELTA method decides that the determination

does not need to run, then the CHECK method is not called.

It’s difficult to come up with any meaningful examples of when you might use the

CHECK method. (Maybe you would only want to fill certain transient nodes for

invoices over $10,000 or for really tall monsters.) Therefore, just to show how

this is done, pretend that you don’t want the determination to run if a monster

has no head, because hat size and sanity become somewhat irrelevant in such a

case.

Listing 8.10 shows how to code the check for a monster having no head. The coding

is even simpler than the CHECK_DELTA method. First, you get the current values

of the header record, then you pass those values to a method of the model

class (ARE_VALUES_DERIVATION_RELEVANT) to evaluate business rules and decide if

you really need to run the determination. Just as before, if you decide that the

determination does not need to run, then you delete a record from the table of

node keys, thus stopping the determination from running.

METHOD /bobf/if_frw_determination~check.

* Local Variables

DATA: lf_determination_needed TYPE abap_bool,

lo_monster_model TYPE REF TO zcl_monster_model,

lt_monster_header TYPE ztt_monster_header,

ls_monster_header LIKE LINE OF lt_monster_header.

io_read->retrieve(

EXPORTING iv_node = zif_monster_c=>sc_node-monster_header

it_key = ct_key

IMPORTING et_data = lt_monster_header ).

READ TABLE lt_monster_header INTO ls_monster_header INDEX 1.

CHECK sy-subrc EQ 0.

lo_monster_model = zcl_monster_model=>get_instance( ls_monster_

header-monster_number ).

lf_determination_needed =

lo_monster_model->are_values_derivation_relevant( ls_monster_header ).

CHECK lf_determination_needed = abap_false.

314

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

Saved successfully!

Ooh no, something went wrong!