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

each log in turn until they find the on e with the errors. (Can you guess which

standard SAP transaction I am talking about here? Oh yes, it’s Transaction CO08,

Create Production Order. I always thought it would be lovely if, when looking at

the list of possible logs you could drill into, the empty logs were grayed out.)

The exact way to gray out such buttons varies with the UI technology you’re

using, but in every case you can use the BOPF to see if an action is able to be processed

or not and then gray out or hide the button accordingly.

In the PBO section of the calling program (the controller), you’re in effect going

to do a dummy run of the HOWL action (like running a BAPI in test mode) and only

if this passes can the controller go ahead and let the view add a Howl button the

user can press. If the monster has no head, then the check will fail, and there will

be no button to press.

In Listing 8.12, first you turn your monster number into the GUID key that BOPF

likes. Then, you fill up the input structure that the HOWL action will be expecting;

just ask for one howl, because if that doesn’t work, then no amount of howls will

work. For technical reasons, you have to turn the input structure into an object of

TYPE REF TO DATA . Then, call the check_action method of the business object’s

service manager, and pass the manager a co nstant that refers to the name of the

action to be checked (namely, howl_at_the_moon). As I mentioned earlier, calling

a generated class directly breaks encapsulation.

If the failed_action_keys table contains any entries after the check_action

method call, then the monster is unable to howl, and the controller should not

allow the view to add the Howl button to the user interface.

*Local Variables

TRY.

* To get a BOPF object, we need a key, not a number

DATA : ld_monster_key TYPE /bobf/conf_key.

ld_monster_key =

get_bopf_key_4_monster_number( id_monster_number ).

* Now we put the key into a one line table

DATA lt_key TYPE /bobf/t_frw_key.

FIELD-SYMBOLS <ls_key> LIKE LINE OF lt_key.

APPEND INITIAL LINE TO lt_key ASSIGNING <ls_key>.

<ls_key>-key = ld_monster_key.

* Populate the parameter structure that contains parameters passed

* to the action:

317

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

Saved successfully!

Ooh no, something went wrong!