‎2021 Feb 19 2:35 PM
I wonder if this is best practice for returning a boolean variable for a given condition.
Here is an example program:
CLASS class DEFINITION.
PUBLIC SECTION.
METHODS is_x
IMPORTING
string TYPE string
RETURNING VALUE(is_x) TYPE abap_boolean.
ENDCLASS.
CLASS class IMPLEMENTATION.
METHOD is_x.
IF ( string = 'x' ).
is_x = abap_true.
ELSE.
is_x = abap_false.
ENDIF.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA(class) = NEW class( ).
IF ( class->is_x( string = 'x' ) ).
WRITE: 'Yes'.
ELSE.
WRITE: 'No'.
ENDIF.
‎2021 Feb 19 2:47 PM
Hi!
Check the sections Use ABAP_BOOL for Booleans and Use XSDBOOL to set Boolean variables in the Clean ABAP guidelines...
‎2021 Feb 19 2:47 PM
Hi!
Check the sections Use ABAP_BOOL for Booleans and Use XSDBOOL to set Boolean variables in the Clean ABAP guidelines...
‎2021 Feb 19 2:57 PM
You don't need parenthesis after IF (must be a java/C habit 😄 )
It's abap_bool, not abap_boolean.