Show TOC

Implementation of ValidationsLocate this document in the navigation structure

Use

To create a validation, the implementing class of the validation must be implemented. This class corresponds to a common ABAP class (with the /BOBF/IF_FRW_VALIDATION interface implemented). If you create the validation using Business Object Builder (BO Builder), the generated class already implements this interface.

The validation interface /BOBF/IF_FRW_VALIDATION consists of the following methods:

Method

Description

CHECK_DELTA

This optional method checks the relevance of node instances to the execution of the validation, based on changes made since the last validation run (if there was a run) at the field level. For action validations, this method is not executed because changes to action validations are made before this point in time and are therefore not relevant.

CHECK

This optional method checks the relevance of node instances to the execution of the validation based on field values. This method does not have access to a before state and is therefore not capable of checking whether any relevant changes were made on node instances.

EXECUTE

This mandatory method executes the validation. It has no direct modifying access to the node data but returns a set of failed keys to identify all inconsistent node instances.

Example

The following source code describes an action validation. The action validation ensures that only node instances with a valid business object partner instance can be processed by the INVOICE_ISSUED action.

METHOD /bobf/if_frw_validation~execute.
 DATA:
  ls_key    TYPE      /bobf/s_frw_key,
  ls_location  TYPE      /bobf/s_frw_location,
  lt_key_link  TYPE       /bobf/t_frw_key_link,
  lo_cm      TYPE REF TO   cm_bopf_training.

 " clear exporting parameter
 CLEAR:
  et_failed_key,
  eo_message.
 " get the party node instances of the IT_KEY root instances
 io_read->retrieve_by_association(
  EXPORTING
   iv_node    = if_ci_bopf_customer_invoi_c=>sc_node-root
   it_key    = it_key
   iv_association = if_ci_bopf_customer_invoi_c=>sc_association-root-party
   iv_fill_data  = abap_false
  IMPORTING
   et_key_link = lt_key_link ).
 LOOP AT it_key INTO ls_key.
  READ TABLE lt_key_link with KEY source_key = ls_key-key TRANSPORTING NO FIELDS.
  IF sy-subrc <> 0.
  " this node instance has no corresponding party instance
   INSERT ls_key INTO TABLE et_failed_key.
   CLEAR ls_location.
   ls_location-node_key = is_ctx-node_key.
   ls_location-key   = ls_key-key.
   CREATE OBJECT lo_cm
    EXPORTING
     textid    = cm_bopf_training=>missing_bill_to_party
     severity    = /bobf/cm_frw=>co_severity_error
     lifetime   = /bobf/if_frw_c=>sc_lifetime_set_by_bopf
     symptom     = /bobf/if_frw_message_symptoms=>co_bo_inconsistency
     ms_origin_location = ls_location.
   IF eo_message IS NOT BOUND.
    CALL METHOD /bopf/cl_frw_factory=>get_message
     RECEIVING
      eo_message = eo_message.
   ENDIF.
   eo_message->add_cm( lo_cm ).
  ENDIF.
 ENDLOOP.
ENDMETHOD.