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

If you compare the coding for the normal validation (Listing 8.14) to the coding

for the action validation (Listing 8.18), then you will see that there is only one

line that is different—namely, the meth od you call in the monster model class.

Even the precise error message is passed back transparently via the exception.

Again, every time you see identical code li ke this it cries out to be in its own

helper method, with only the aspect that varies being passed in as a parameter.

Finally, test this using Transaction /BOBF/TEST_UI. Set a monster record to have

no head, and then try to execute the HOWL action (Figure 8.28).

Figure 8.28 Testing an Action Validation

The most common action validation is checking that a record is ready to be saved

or changed in the database. Usually, that’s handled by the consistency validation

that is called automatically by BOPF pr ior to the record being saved, but you

might conceivably need an action validation as well. You most likely will not, but

be aware of the possibility.

8.2.9 Saving to the Database

Once the user has made all his changes or entered all his data for a new record

and the program has validated that the da ta is consistent, the time has come to

click the Save button and update the database.

335

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

Saved successfully!

Ooh no, something went wrong!