Report Ignored PREFERRED PARAMETER When Non-Optional Parameters Exist
Overview
Report ignored PREFERRED PARAMETER addition.
ATC Finding Message:
PREFERRED PARAMETER is ignored when mandatory parameters exist
Rationale
In ABAP methods, PREFERRED PARAMETER specifies the default importing parameter for positional calls. However, according to SAP ABAP rules, PREFERRED PARAMETER is ignored if there are any mandatory (non-optional) importing parameters in the signature. Such declarations mislead developers into assuming positional calls will work when in fact they are invalid or ignored.
Non-Compliant
abap
METHODS get_data
IMPORTING
iv_req TYPE i
iv_opt TYPE i OPTIONAL
PREFERRED PARAMETER iv_req.Compliant
abap
METHODS get_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 NO_IGN_PREF_PARAM
" SAP CI_ prefix format:
... "#EC CI_NO_IGN_PREF_PARAMRelated Rules
- Declare OPTIONAL and DEFAULT Parameters Last —
#EC PREF_OPTIONAL_LAST - Limit Method Parameter Count and Keep One Parameter per Line —
#EC MAX_PARAMS_COUNT
Technical Details
- Native ATC Class:
/SKYL/CL_NO_IGN_PREF_PARAM - ABAP Implementation: /skyl/cl_no_ign_pref_param.clas.abap
- Rule Metadata: rules-data.mjs (Line 5989)