ABAP Code Sample – ABAP_BOOL

ABAP_BOOL

 

It has become common practice to express the truth value “true” as value “X” and the truth value “false” as a blank (” “).

To make it easier to handle truth values expressed in this way, the TYPE GROUP abap contains a data type abap_bool of elementary type c with length 1, and the constants

  • abap_true of value “X”
  • abap_false of value ” “
  • abap_undefined of value “-“

When working explicitly with truth values, use the type abap_bool as a substitute for a real boolean data type.

Writing your code this way will make it easy to understand and maintain.

Here is an example of Good and Bad ABAP Coding practice.

Bad example

BAD Sample Code using ABAP Truth Value

Good example

The following source code shows the recommended way to write your program using of the boolean data.

Good Sample Code using ABAP Truth Value

5 Comments

  1. TuGR

    Hi,
    Thanks for the tips.
    I got an error : abap_bool undefined :

    TYPE-POOLS ABAP.
    FIND LIKE ABAP_BOOL.

    Can you help me ? Thanks !

  2. srinivas chary

    IF cl_sd_bill_switch_check=>sd_sfws_mev_01( ) = abap_true AND
    cl_sd_doc_category_util=>is_bill_period_end( tvfk-vbtyp ) = abap_true.

    here im getting error…
    can u plz

Leave a Reply to srinivas chary Cancel reply

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