Negation logic in SAP ABAP

You can use BOOLC to sort out your negation logic requirement. It should be like this ?

Varbool = BOOLC( NOT Logical_operation )

But be clear in your implementation, as ABAP does not have a true bool type. It does not store true or false in bool type rather it stores 'X' or '' (empty string) for true and false respectively.

Example with BOOLC

Here's a practical example showing negation logic using BOOLC ?

DATA: lv_number TYPE i VALUE 10,
      lv_result TYPE c LENGTH 1.

" Using BOOLC with NOT for negation
lv_result = BOOLC( NOT lv_number GT 20 ).

" lv_result will contain 'X' because NOT(10 > 20) is true

Alternative with XSDBOOL

You can also use XSDBOOL instead of BOOLC. The XSDBOOL function returns XML schema boolean values ?

DATA: lv_number TYPE i VALUE 15,
      lv_result TYPE string.

" Using XSDBOOL with NOT for negation
lv_result = XSDBOOL( NOT lv_number LT 10 ).

" lv_result will contain 'true' because NOT(15 

The key difference is that XSDBOOL returns 'true' or 'false' as string values, while BOOLC returns 'X' or '' (empty) following ABAP conventions.

Conclusion

Both BOOLC and XSDBOOL functions effectively handle negation logic in ABAP, with the choice depending on whether you need ABAP-style boolean representation or XML schema boolean format.

Updated on: 2026-03-13T18:17:55+05:30

679 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements