SAP ABAP Data Element O2VALIDATE (BSP Element: User-Defined Validation)
Hierarchy
SAP_BASIS (Software Component) SAP Basis Component
   BC-BSP (Application Component) Business Server Pages
     SBSP_DEVTAGLIB (Package) Development Environment Objects for Taglib Support
Basic Data
Data Element O2VALIDATE
Short Description BSP Element: User-Defined Validation  
Data Type
Category of Dictionary Type D   Domain
Type of Object Referenced     No Information
Domain / Name of Reference Type CHAR1    
Data Type CHAR   Character String 
Length 1    
Decimal Places 0    
Output Length 1    
Value Table      
Further Characteristics
Search Help: Name    
Search Help: Parameters    
Parameter ID   
Default Component name    
Change document    
No Input History    
Basic direction is set to LTR    
No BIDI Filtering    
Field Label
  Length  Field Label  
Short 10 Valid. 
Medium 15 Validation 
Long 30 User-Defined Validation 
Heading  
Documentation

Definition

Activate this option if you want to execute a user-defined validation of the element call - for example, to check the correct type of attribute values. Validation can take place at the time of compiling or at runtime.

Error messages that occur at the time of compiling lead to a syntax error in the BSP page editor, whilst error messages at runtime lead to an exception and therefore an end to page processing.

Use

As well as activating the option, you must redefine the interface methods COMPILE_TIME_IS_VALID and/or RUNTIME_IS_VALID in the element handler class.

Within the method COMPILE_TIME_IS_VALID the return value valid must be ascertained accordingly; you can use predefined help methods of the object validator (IMPORTING parameters for the method) to check the data types that are frequently used.

Within the method RUNTIME_IS_VALID corresponding methods of the object m_validator (statistical attribute of interface IF_BSP_ELEMENT), whereby in addition to the name of the attribute to be checked, its value is also transferred. You do not have to set a return value here; if an error occurs when checking a method of m_validator, the runtime automatically triggers an exception and BSP page processing ends.

Dependencies

Example

We want to check at the time of compiling whether the value of the attribute "ignoreCase" is a correct Boolean value. For this the COMPILE_TIME_IS_VALID method is overwritten:

METHOD IF_BSP_ELEMENT~COMPILE_TIME_IS_VALID. 
validator->to_boolean( name = 'ignoreCase' ).
valid = validator->m_all_values_valid.
ENDMETHOD.

Validation at runtime could be as follows:

METHOD IF_BSP_ELEMENT~RUNTIME_IS_VALID. 
m_validator->to_boolean( name = 'ignoreCase'
value = me->ignorecase ).
ENDMETHOD.
History
Last changed by/on SAP  20040312 
SAP Release Created in 620