This is a test message to test the length of the message box.
ABAP BOPF Validation
Created by Software-Heroes

ABAP - BOPF Validation

What's the easiest way to keep your data model clean? The simple answer you will learn today.

The topic of cleanliness of the data is also very important in the BOPF and provides with the validations a strong method of checking consistency. Similar to the determination, the validation in the data model is also created on the corresponding node. Today we'll show you how to define a validation and implement the appropriate logic in the class.


Create a validation

The validation, like the determination, is again defined on the corresponding node to which it applies. To do so, right-click and select "Consistency validation" to create a new empty object.


Fill in the name and description of the validation and then you can generate the class name again by suggestion of the system.


The condition must now be activated for certain actions (triggers). In this case, we activate it for all cases, except for deletion, since it makes no sense there. You can only go through validations during generation, if the data is then no longer changeable.



The logic is again implemented in the created class implementing the interface /BOBF/IF_FRW_VALIDATION. In the EXECUTE method, all checks are implemented on the data, with the following example:

  lt_price_data TYPE ztest_t_price_scale.

eo_message = /bobf/cl_frw_factory=>get_message( ).

    iv_node       = is_ctx-node_key
    it_key        = it_key
    iv_fill_data  = abap_true
    et_data       = lt_price_data

LOOP AT lt_price_data REFERENCE INTO DATA(lr_price_data).
  DATA(ld_error) = abap_false.

  IF lr_price_data->min_quantity <= 0.
    ld_error = abap_true.

  IF lr_price_data->discount < 0.
    ld_error = abap_true.

  IF ld_error = abap_true.
    APPEND VALUE #( key = lr_price_data->key ) TO et_failed_key.

        is_msg       = VALUE #( msgty = 'E'
                                msgid = 'ZTEST_MSG'
                                msgno = '001'
        iv_node      = is_ctx-node_key
        iv_key       = lr_price_data->key


The data must first be read from the data model, because at this point only the keys are available. Afterwards, the data is checked for correctness. If the data has an error, then the key must be transferred to the failed keys table and a message can be generated. In any case, make sure that a new message instance has been created by the factory method before adding the message.



When creating the test data, we will now receive a corresponding error message if the data is not filled correctly. The data can only be backed up if there are no more validation errors.



Consistent data in the data model should no longer be a problem for you. With today's article, you can do simple data checks at runtime. Have fun trying it out with your own solution.

Included topics:
BOPFValidationCheck data
Comments (0)

ABAP - BOPF Quick Guide (Update)

Category - ABAP

A little update to our book that we published. For all people who find the paperless office boring.


ABAP - BOPF Quick Guide

Category - ABAP

You need a quick introduction to the SAP Business Object Processing Framework (BOPF), we have the right guide for you here.


ABAP - BOPF Eclipse

Category - ABAP

Can you also develop BOPF in Eclipse? Here we show you how well the search and navigation works in the system.


ABAP - BOPF Performance

Category - ABAP

What about the performance when accessing BOPF? We want to investigate this question today.


ABAP - BOPF Helper methods

Category - ABAP

The framework provides you with various methods and objects that are intended to simplify use.