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

and Section 8.2.5, you’ll look at elements of BOPF that are analogous to the initial

screen on which you enter yo ur monster number and click Display or Change.

This encompasses tasks such as checking whether the monster record already

exists, whether the current user is author ized to view or change it, and whether

the record is locked by another user. Next, you’ll look at the BOPF equivalents of

PBO (process before output) processing (what the program does before the data is

presented to the user) in Section 8.2.5 and Section 8.2.6. The tasks in question are

filling out certain fields based on the va lues of others and disabling certain user

commands in certain circumstances. Natu rally, the section ends with the BOPF

equivalents of PAI (process after input) in Section 8.2.7, Section 8.2.8, Section

8.2.9, and Section 8.2.10. Tasks here involve checking user input to make sure

the data is consistent, acting upon comm ands the user has invoked, saving the

record to the database, and creating change documents to track what fields the

user has changed.

8.2.1 Creating Model Classes

This is a good time to prepare yourself to be puzzled. In the next section, you’ll

see how to code the existence check for a BOPF object. You probably know that

this requires about two lines of code in the way you’ve always done things (it’s a

simple SQL query). So when you first see the equivalent BOPF code, which goes

on for pages, it’s easy to decide that BOPF is overcomplicated, ridiculous, or in

the too-hard basket—and switch off and walk away. Try and keep an open mind

until you understand how this all works, because only then can you truly make an

informed decision as to whether BOPF speeds up or slow s down application

development.

Note

Although there’s a lot of detail presented in the upcoming discussion (so that you can

understand what’s going on), Section 8.3. 2 will talk about wrapping mundane boiler

plate tasks in reusable classes with simple interfaces so that you never have to worry

about such details again. This is in fact exactly what SAP itself does internally.

Now, have I scared you enough? Yes? Good! In that case, it’s time to look at how

to start coding a BOPF model class.

You’re going to create class ZCL_MONSTER_MODEL to hold the routines you’ll be

using to manipulate your BOPF monster. As you’ll see shortly, you need instances

291

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

Saved successfully!

Ooh no, something went wrong!