Skip to content

Split method instead of Boolean input parameter

Boolean input parameters are often an indicator that a method does two things instead of one.

" anti-pattern
METHODS update
  IMPORTING
    do_save TYPE abap_bool.

Also, method calls with a single - and thus unnamed - Boolean parameter tend to obscure the parameter’s meaning.

" anti-pattern
update( abap_true ).  " what does 'true' mean? synchronous? simulate? commit?

Splitting the method may simplify the methods’ code and describe the different intentions better

update_without_saving( ).
update_and_save( ).

Common perception suggests that setters for Boolean variables are okay:

METHODS set_is_deleted
  IMPORTING
    new_value TYPE abap_bool.

Read more in 1 2 3

From SAP/styleguides under CC BY 3.0 — more details
Last updated on