Skip to content

Limit Method and Constructor Statement Length ​

WarningMetrics & Complexity Limits#EC MAX_METHOD_LENRemote Enabled

Overview ​

Method and Constructor Length Limits.

ATC Finding Messages:

  • Method length exceeds maximum allowed statement limit
  • Avoid heavy business logic/loops in constructor; use injection only

Rationale ​

Methods that contain hundreds of statements violate the Single Responsibility Principle (SRP). They are difficult to comprehend, impossible to unit test thoroughly, and conceal copy-pasted business logic branches. Constructors are especially sensitive: heavy business logic or loops in constructors make dependency injection and mock testing impossible.

Clean ABAP Guideline: A clean method should do one thing, do it well, and do it only. Keep regular methods under 20-30 statements and keep constructors minimal (dependency assignment only).

Non-Compliant ​

abap
" Anti-pattern: Overly long method combining validation, calculation, DB updates, and logging
METHOD process_sales_order.
  " 150+ lines of mixed concerns...
  " Validation logic
  " Database reads
  " Currency conversion
  " Pricing calculations
  " Direct database updates
  " Email dispatch
ENDMETHOD.

Compliant ​

abap
" Clean ABAP: Short, focused methods delegating to dedicated domain services
METHOD process_sales_order.
  validate_order_data( is_order ).
  DATA(ls_pricing) = mo_pricing_service->calculate( is_order ).
  mo_order_repository->save( is_order = is_order is_pricing = ls_pricing ).
  mo_notifier->send_confirmation( is_order-order_id ).
ENDMETHOD.

Configuration & Thresholds ​

This check can be fine-tuned directly in the ATC Check Variant Editor (CHKV) in Eclipse ADT:

Parameter NameData TypeDefault ValueDescription & Guidance
MAX_STATEMENTSInteger5Maximum executable ABAP statements allowed in regular method bodies
MAX_CTOR_STATEMENTSInteger10Maximum statements allowed in CONSTRUCTOR methods (guards against heavy setup logic)

Suppression ​

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

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

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

Technical Details ​

Released under the MIT License.