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:
1 2 3 4 5 | IF sy-subrc = 0. result = abap_true . ELSE . result = abap_false . ENDIF . |
1 2 | result = SWITCH #( sy-subrc WHEN 0 THEN abap_true ELSE abap_false ). |
1 | result = xsdbool ( sy-subrc = 0 ) |