Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Flipping a boolean return value from a method

former_member333493
Participant
3,776

I have a public static method in a class which has a returning variable of type BOOLE ('X' for true, ' ' for false). I want to store the negation of the value returned by this method into a variable lv_result (type c length 1). Is this possible without the use of a third variable?

Ideally I'm roughly looking for something as follows:

LV_RESULT = ( NOT cl_class_api=>method (EXPORTING iv_var = lv_var) ).

1 ACCEPTED SOLUTION
Read only

Sandra_Rossi
Active Contributor
2,219

Use boolc or xsdbool:

LV_RESULT = xsdbool( abap_false = cl_class_api=>method( EXPORTING iv_var = lv_var) ).

(if the method returns false then it gives true, and if the method returns true then it gives false)

3 REPLIES 3
Read only

Sandra_Rossi
Active Contributor
2,220

Use boolc or xsdbool:

LV_RESULT = xsdbool( abap_false = cl_class_api=>method( EXPORTING iv_var = lv_var) ).

(if the method returns false then it gives true, and if the method returns true then it gives false)

Read only

0 Likes
2,219

Apart from abap_false in place of false, this seems perfect.

Read only

2,219
Aveek Kumar Baruah well seen, corrected!