The Boolean functions boolc and xsdbool can be used to determine the truth value of logical expressions. A logical expression can be specified as an argument for those functions.

For example, the following logical expression is true when the string length is > 0:

strlen( 'abc' ) > 0


Usually, we would find these expressions as part of an IF-statement like this:

IF strlen( 'abc' ) > 0.
...
ENDIF.


In case you want to store the truth value of such an expression in a variable you need to use a Boolean function.

## Boolean Function boolc

DATA(string_not_initial) = boolc( strlen( 'abc' ) > 0 ).

• The data type is a single-character string
• Returns ‘X’ if boolean true
• Returns ' ' if boolean false
• If the logical expression is false, the result of boolc does not meet the condition IS INITIAL
• Cannot be used like a value of the type abap_bool and be compared with the constants abap_true & abap_false

## Boolean Function xsdbool

DATA(string_not_initial) = xsdbool( strlen( 'abc' ) > 0 ).

• The data type is type c with length 1
• Returns ‘X’ if boolean true
• Returns ' ' if boolean false
• If the logical expression is false, the result of boolc meets the condition IS INITIAL
• Can be used like a value of the type abap_bool and be compared with the constants abap_true & abap_false`