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)

DATA ls_parameters TYPE zsa_howl_at_the_moon.

DATA lr_s_parameters TYPE REF TO data.

* If not even one howl is possible, no point in going on

ls_parameters-no_of_howls = 1.

GET REFERENCE OF ls_parameters INTO lr_s_parameters.

* Check to see if the HOWL action can be invoked:

DATA lo_message TYPE REF TO /bobf/if_frw_message.

DATA lt_failed_key TYPE /bobf/t_frw_key.

DATA lt_failed_act_key TYPE /bobf/t_frw_key.

CALL METHOD mo_service_manager->check_action

EXPORTING

iv_act_key = zif_monster_c=>sc_action-root-howl_at_the_moon

it_key = lt_key

is_parameters = lr_s_parameters

IMPORTING

eo_message

= lo_message

et_failed_key = lt_failed_key

et_failed_action_key = lt_failed_act_key.

IF lt_failed_act_key[] IS NOT INITIAL.

"The action would fail – do not add the button

ENDIF.

CATCH /bobf/cx_frw INTO lx_frw.

"The action would fail really badly, do not add the button

ENDTRY.

Listing 8.12 Invoking an Action Validation Manually

Note

In Section 8.2.8, you will look at how user commands are processed in BOPF using

actions and how an action validation is run automatically by the framework just before

a user command (action) is executed.

8.2.7 Checking Data Integrity Using Validations

Before you save your data to the database, you want to be sure it’s in a consistent

state. In fact, you want to check this not only at the time of saving but often many

times throughout the transaction. In BOPF, this is handled via validations. Validations

are called automatically during sa ve, but can also be called on demand.

Often, in DYNPRO programs the equivalent code to perform a validation is called

after every user entry (i.e., during PAI) , but that could seem excessive; in any

318

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

Saved successfully!

Ooh no, something went wrong!