Homelab, Linux, JS & ABAP (~˘▾˘)~
 

[ABAP] xsdbool

Somehow I always forget that there is a boolean function in ABAP. That’s why I’m writing this post to hopefully remember it better. 🙂

If you just want to check something for truthiness, you can do it in the following three ways:

IF sy-subrc = 0.
  result = abap_true.
ELSE.
  result = abap_false.
ENDIF.
result = SWITCH #( sy-subrc WHEN 0 THEN abap_true
                                   ELSE abap_false ).
result = xsdbool( sy-subrc = 0 )

https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abenboole_functions.htm?file=abenboole_functions.htm

https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#use-xsdbool-to-set-boolean-variables

Leave a Reply

Your email address will not be published. Required fields are marked *