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

Coding the Action

Now that the action has been created, you have to code it. The first step is to create

a public method for howling at the m oon. This will have a single importing

parameter that corresponds to the stru cture you defined when creating your

action in BOPF—namely, ZSA_HOWL_AT_THE_MOON. (You could have a totally different

signature if you wanted, because the BOPF-generated action class can adapt

the generated input structure to the sign ature of the model. This would be the

case if you were hooking up an already existing model class to BOPF.)

Because methods of a model class can do literally anything that can be imagined

(in real actions, you update the current state of the object, or save it to the database,

or send an instruction to an exte rnal system), you will just have a method

with a few lines of code that sends a message to the SAP GUI (Listing 8.15) in your

model class and will concentrate on how to call this from BOPF.

METHOD howl_at_the_moon.

DO is_howl_request-no_of_howls TIMES.

MESSAGE 'Ooooooooooooooooooooooooo' TYPE 'I'.

ENDDO.

ENDMETHOD. "Howl at the Moon

Listing 8.15 Coding the Howl at the Moon Action in the Model Class

With that piece of programming genius out of the way, it’s time to turn to coding

the generated action class. Th e generated class implements the /BOBF/IF_FRW_

ACTION interface, which gives you three methods:

왘 RETRIEVE DEFAULT PARAM

This method sends out a list of what input fields are needed to call the action.

It’s remotely possible that a calling application might need the structure of the

action input parameter for some reason. If the parameter structure keeps

changing dramatically (e.g., if in th e BOPF definition the DDIC type of the

input parameter structure is changed), then the calling program might want to

fill the parameter fields dynamically so that the calling program does not have

to change when the BOPF object changes the parameter. That isn’t very likely,

though. This method is optional.

왘 PREPARE

An action can be performed on more thanone object, and this method lets you

limit the number of objects the acti on is performed upon. The difference

327

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

Saved successfully!

Ooh no, something went wrong!