Skip to content

Declare Optional and Default Parameters Last in Methods ​

WarningClean ABAP & Modern Syntax#EC PREF_OPTIONAL_LASTRemote Enabled

Overview ​

Declare optional and default parameters last in methods.

ATC Finding Message: Declare mandatory parameters before OPTIONAL and DEFAULT parameters

Rationale ​

In Clean ABAP, mandatory parameters must appear before optional (OPTIONAL) and default (DEFAULT) parameters in method signatures. Mixing optional and required parameters makes caller invocation confusing and error-prone.

Standard: Place required parameters first, followed by optional parameters at the end of the parameter list.

Non-Compliant ​

abap
METHODS process_data
  IMPORTING
    iv_opt TYPE i OPTIONAL
    iv_req TYPE i.

Compliant ​

abap
METHODS process_data
  IMPORTING
    iv_req TYPE i
    iv_opt TYPE i OPTIONAL.

Suppression ​

To suppress findings for this rule, append the pseudo-comment to the statement:

abap
" Standard pseudo-comment:
... "#EC PREF_OPTIONAL_LAST

" SAP CI_ prefix format:
... "#EC CI_PREF_OPTIONAL_LAST

Technical Details ​

Released under the MIT License.