ABAP Keyword Documentation → ABAP - Reference → Program Flow → Expressions and Functions for Logical Expressions → Logical Functions
boolc, boolx - Boolean Functions
The arguments of Boolean functions are logical expressions. The return value of a Boolean function expresses the truth value of the logical expression.
Other versions: 7.31 | 7.40 | 7.54
Syntax Forms
Effect
The functions determine the truth
value of the logical expression log_exp.
For log_exp, any logical expression can be specified in accordance with the applicable rules.
The return value is as follows:
- The function
boolcreturns a single-character character string of the typestring. If the logical expression is true, "X" is returned. If the logical expression is false, a blank character is returned.boolcbasically belongs to the processing functions with character-type results and can be specified in general and character-type expression positions.
- The function
boolxreturns a byte chain of the typexstring. If the logical expression is true, the byte chain is filled as if the function bit_set( bit ) were being executed. If the logical expression is false, the byte chain is filled as if the function bit_set( 0 ) were being executed. Forbit, a data object of the typeimust be specified.boolxbelongs, in principle, to the Bit functions and can be used at all position where a Bit expression, too, is possible
Notes
- These functions can be viewed as a partial replacement for the boolean data type for truth values
not available in ABAP. In particular, you can use
boolcin many operand positions where input parameters of the typeabap_boolof the type groupABAP are expected.
- The result of
boolcmust not, however, be compared in logical expressions with the constantsabap_trueandabap_false, since the comparison converts the latter fromctostringand ignores any blanks. Comparisons of this type are not usually necessary.
- If
boolcrequires return values other than "X" or " " (for example, "Y" and "N" or "1" and "0"), the result ofboolccan be edited using the functiontranslateor another suitable processing function.
- The function
boolxcan be used for efficient saving of sequences of truth values.
Example
The value 0, 1, or 2 is assigned to the variable bool_value, depending on the result of the logical expressions log_exp1 and log_exp2.
bool_value = strlen( condense( val = boolc( log_exp1 ) ) ) +
strlen( condense( val = boolc( log_exp2 ) ) ).
Example
Calling a method, where the input parameter no_dialog is supplied with the character-like representation of the results of a logical expression.
PARAMETERS word TYPE c length 30.
DATA result_tab TYPE cl_abap_docu=>search_results.
cl_abap_docu=>start(
EXPORTING word = word
no_dialog = boolc( sy-batch IS NOT INITIAL )
IMPORTING search_results = result_tab ).