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.

Using BOPF to Write a DYNPRO-Style Program 8.2

DELETE ct_key WHERE key = ls_monster_header-key.

ENDMETHOD. "Check

METHOD are_values_derivation_relevant.

IF is_header_values-no_of_heads > 0.

rf_relevant = abap_true.

ELSE.

rf_relevant = abap_false.

ENDIF.

ENDMETHOD.

Listing 8.10 Coding the CHECK Method for a Determination

The EXECUTE Method

The EXECUTE method is the method that actually does the determination (i.e.,

changes some values based on others), provided the CHECK_DELTA and CHECK

methods allow it to be run. From a tech nical point of view, the important thing

about this method is that not only do you get an imported (via the method parameters)

object, READ, which allows you to read the current values, but also another

imported object, MODIFY, which lets you modify these values.

In Listing 8.11, you can see that there are three simple steps to executing a determination.

First, you use the imported object READ to get the values from the database

for a given monster (or many monsters at once, given that a table of the keys

is being passed in). Then, create an instance of your model class and perform the

monster-specific logic (i.e., logic that would be the same no matter what framework

you were using) to fill up the tr ansient fields. Finall y, use the imported

object MODIFY to pass back the completed combined structure to BOPF.

METHOD /bobf/if_frw_determination~execute.

* Local Variables

DATA: lt_monster_header TYPE ztt_monster_header,

ls_monster_header LIKE LINE OF lt_monster_header,

lo_monster_model TYPE REF TO zcl_monster_model.

* Clear Exporting Parameters

CLEAR: eo_message,

et_failed_key.

* Get the persistent (database) values

io_read->retrieve(

EXPORTING iv_node = zif_monster_c=>sc_node-monster_header

it_key = it_key

315

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

Saved successfully!

Ooh no, something went wrong!