‎2006 Nov 16 2:42 PM
Hello,
I am wondering how do you write a boolean statment in ABAP. I tried to do something like this below:
bool = text1 IS initial OR text2 IS initial.
where text1 and text2 are text boxes in the selection screen.
And I ended up having error like this:
Incorrect arithmetic or bit expression: Instead of "IS", an operator (+, -, *, /, ... or BIT-AND, BIT-XOR, BIT-OR) was expected.
What is wrong with the statement above? Thanks!
Regards,
Anyi
‎2006 Nov 16 2:57 PM
Really there is no boolean in ABAP, it is just a TYPE C field with either an "X" or a SPACE. But you can write something like this.
report zrich_0001.
type-pools: abap.
constants: true type abap_bool value 'X'.
constants: false type abap_bool value ' '.
data: value type c.
if value = true.
elseif value = false.
endif.
Regards,
Rich Heilman
‎2006 Nov 16 2:47 PM
Hi
IF TEXT1 IS INITIAL OR
TEXT2 IS INITIAL.
* Do something
ENDIFMax
‎2006 Nov 16 2:49 PM
Hullo,
IIRC there is no such thing as a boolean in ABAP.
However, you can solve this using an IF statement:
DATA: bool(1) TYPE c.
IF text1 IS INITIAL OR text2 IS INITIAL.
bool = 'T' .
ELSE.
bool = 'F'.
ENDIF.Where the values 'T' stands for true and 'F' stands for false. (Usually in ABAP the value for true is 'X' and ' ' for false though).
Hope this helps.
‎2006 Nov 16 2:50 PM
‎2006 Nov 16 2:57 PM
Really there is no boolean in ABAP, it is just a TYPE C field with either an "X" or a SPACE. But you can write something like this.
report zrich_0001.
type-pools: abap.
constants: true type abap_bool value 'X'.
constants: false type abap_bool value ' '.
data: value type c.
if value = true.
elseif value = false.
endif.
Regards,
Rich Heilman
‎2006 Nov 16 3:00 PM
hi Anyi,
There is no boolean type defined in ABAP like any other language.
Boolean hold the value true or false - all those cases where you need to check you can use if else statement. ie
if (Condition1 is true)
//code....111
else.
//code...222
endif.This is the way to handle the use of boolean in ABAP. Actually ABAP does not need boolean datatype.
Regards,
Richa.