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

event, you could run the validation on every roundtrip if you wanted, or only

when the user presses some sort of Check button, just like when you’re entering

a supplier invoice in Transaction MIRO.

What actually defines a consistent object is naturally very application-specific; for

example, a sales order with no items or no customer is not much good. In this example,

say that if you enter a hat size for the monster, then the monster has to have a

head. It’s always the job of the model to know what data is consistent and what is

not. Using this example, you’ll learn how to create and then code a validation.

Creating the Validation

To create the validation, open Transaction BOB, and select the MONSTER_HEADER

node. Right-click on it, and choose the context menu option Create Consistency

Validation. By this point, it will probably not come as much of a shock to you

that a wizard appears to guide you thro ugh the creation process. The first two

screens are nothing special: just choose a name (which will be used to generate

the implementing class) and a text descri ption, and then the name of the implementing

class is proposed.

This time, you can choose when the vali dation will be run by selecting checkboxes

(Figure 8.15). Note that you can, for example, tell the system to run a validation

on the header data when item data is changed or vice versa.

Figure 8.15 Choosing when a Validation Runs

Note that the checkboxes in Figure 8.16 control the automatic running of the validation

by the framework at update time. Because the validation is implemented

319

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

Saved successfully!

Ooh no, something went wrong!