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

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(

EXPORTING iv_node = zif_monster_c=>sc_node-monster_header

it_key = it_key

IMPORTING et_data = lt_monster_header ).

READ TABLE lt_monster_header INTO ls_monster_header INDEX 1.

CHECK sy-subrc EQ 0.

* Use the model to actually perform the logic check

lo_monster_model =

zcl_monster_model=>get_instance( ls_monster_header-monster_number ).

TRY.

lo_monster_model->validate_monster_header( ls_monster_header ).

CATCH zcx_monster_exceptions INTO lo_monster_exception.

DATA: ls_key LIKE LINE OF it_key.

READ TABLE it_key INTO ls_key INDEX 1. "Only one line

"This key (node) has failed at the job of being consistent

INSERT ls_key INTO TABLE et_failed_key.

"Create the bottle for our message

eo_message = /bobf/cl_frw_factory=>get_message( ).

* Now we send the error message in the format the BOPF Framework

* desires

DATA: ls_location TYPE /bobf/s_frw_location,

lo_message TYPE REF TO /bobf/cm_frw_core.

ls_location-node_key = is_ctx-node_key.

ls_location-key = ls_key-key. "I heard you the first time

CREATE OBJECT lo_message

EXPORTING

323

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

Saved successfully!

Ooh no, something went wrong!