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_LASTRelated Rules
- Method Call Parameter Naming Style (Omit or Require) —
#EC PREF_PARAM_NAME - Single Parameter or Field Per Line —
#EC PREF_PARAM_1LINE - Limit Method Parameter Count and Require Multi-Line Signatures —
#EC MAX_PARAMS_COUNT
Technical Details
- Native ATC Class:
ZCL_SKYLINT_PREF_OPT_LAST - Implementation File: zcl_skylint_pref_opt_last.clas.abap