ABAP BOOLC Function: A Quick Guide
The BOOLC function in ABAP converts logical expressions into a character string 'X' (for true) or an empty string '' (for false). This can be particularly useful when you need a string representation of boolean expressions for conditions or output.
Syntax
BOOLC( logical_expression )
Examples
1. Basic Usage
DATA(result) = BOOLC( 5 > 3 ). " result will be 'X'
DATA(result) = BOOLC( 5 = 3 ). " result will be ''
2. Using with Variables
DATA(value1) = 10.
DATA(value2) = 20.
DATA(result) = BOOLC( value1 < value2 ). " result will be 'X'
DATA(result) = BOOLC( value1 = value2 ). " result will be ''
3. Combining with String Operations
DATA(text) = |The statement is { BOOLC( 1 = 1 ) }true.|. " text will be 'The statement is Xtrue.'
DATA(text) = |The statement is { BOOLC( 1 > 2 ) }false.|. " text will be 'The statement is false.'
4. Conditional Assignments
DATA(is_valid) = BOOLC( sy-subrc = 0 ). " is_valid will be 'X' if the last operation was successful