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.

Using BOPF to Write a DYNPRO-Style Program 8.2

Figure 8.27 Action Validation Exception

Next, code the validation logic in your monster model class. This is shown in Listing

8.17, in which an exception is thrown if the monster has no head.

METHOD validate_howl_action.

IF is_header_values-no_of_heads EQ 0.

RAISE EXCEPTION TYPE zcx_monster_exceptions

EXPORTING

textid = zcx_monster_exceptions=>no_head_howling_problem.

ENDIF.

ENDMETHOD. "Validate Howl Action

Listing 8.17 Validating the Howl Action in the Monster Model Class

The final stage is to code the EXECUTE method in your action validation, which is

going to look suspiciously like the code in the consistency validation you created

earlier (see Listing 8.18).

METHOD /bobf/if_frw_validation~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,

lo_monster_exception TYPE REF TO zcx_monster_exceptions.

* Clear Exporting Parameters

CLEAR: eo_message,

et_failed_key.

* Get the current header values

io_read->retrieve(

333

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

Saved successfully!

Ooh no, something went wrong!