ABAP Predefined Function: XSDBOOL
The xsdbool function in ABAP is used to convert a boolean expression into its corresponding string representation ("true" or "false"). This is particularly useful for handling boolean values in XML or web services.This guide covers its syntax, practical examples, and best practices for efficient SAP programming.
Syntax
xsdbool( <logical_expression> )
Examples
DATA: lv_result TYPE string.
" Example 1: Simple comparison
lv_result = xsdbool( 1 = 1 ). " Result: "true"
" Example 2: Complex logical expression
lv_result = xsdbool( ( 3 > 2 ) AND ( 5 < 10 ) ). " Result: "true"
" Example 3: Using variables
DATA: lv_flag TYPE abap_bool VALUE abap_true.
lv_result = xsdbool( lv_flag ). " Result: "true"
" Example 4: Expression with false result
lv_result = xsdbool( 1 = 2 ). " Result: "false"