The cleanest way to flip a boolean

Are there existing methods or function modules that effectively change logical values?

I came up with a simple implementation, should I define my own utility method, but I wonder if this is the most efficient way:

IF iv_bool = abap_true.
    rt_bool = abap_false.
ELSEIF iv_bool = abap_false.
    rt_bool = abap_true.
ELSE.
    rt_bool = abap_undefined.
ENDIF.

EDIT: As Smigs mentioned, this implementation flips the three-digit Boolean or “triline”

+4
source share
1 answer
rt_bool = boolc( iv_bool <> abap_true ).

will flip the boolean value. However, it will not deal with abap_undefined.

740 SP08, xsdbool( ) boolc( ) . , xsdbool( )

+10

Source: https://habr.com/ru/post/1537860/


All Articles