Skip to content

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

  1. ... boolc( log_exp ) ...

  2. ... boolx( bool = log_exp bit = bit ) ...

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 boolx returns a byte chain of the type xstring. 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 type i must be specified. boolx belongs, 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 boolc in many operand positions where input parameters of the type abap_bool of the type groupABAP are expected.

  • The result of boolc must not, however, be compared in logical expressions with the constants abap_true and abap_false, since the comparison converts the latter from c to string and ignores any blanks. Comparisons of this type are not usually necessary.

  • If boolc requires return values other than "X" or " " (for example, "Y" and "N" or "1" and "0"), the result of boolc can be edited using the function translate or another suitable processing function.

  • The function boolx can 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.

DATA bool_value TYPE i.

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 ).