ARTICLE
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.
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 boolc returns a single-character character string of
the type string . If the logical expression is true, "X" is
returned. If the logical expression is false, a blank character is
returned. boolc basically belongs to the
processing functions with character-type
results and can be specified in
general and
character-type expression
positions .
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. For bit , 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,
boolc can be used in many operand positions where input parameters of
the type abap_bool of the type group
ABAP are expected.
The result of boolc must not, however, be compared in relational
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
Calls a method, where the input parameter no_dialog is supplied
with the character-like representation of the results of a predicate
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 ).
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved