Skip to content

Prefer NEW #( ) over CREATE OBJECT ​

WarningClean ABAP & Modern SyntaxQuickFix Ready#EC NEW_OPRemote Enabled

Overview ​

Prefer NEW operator over CREATE OBJECT and RAISE EXCEPTION.

ATC Finding Messages:

  • Prefer NEW #( ) expression over CREATE OBJECT
  • Prefer RAISE EXCEPTION NEW cx_name( ) over RAISE EXCEPTION TYPE

Rationale ​

CREATE OBJECT is the procedural object-creation statement and requires a separate declaration and assignment. NEW #( ) infers the class from the target, can be used inside expressions, and keeps construction close to where the reference is needed. Use NEW for object creation in modern ABAP and reserve CREATE OBJECT for legacy downport code.

Non-Compliant ​

abap
DATA lo_customer TYPE REF TO cl_customer.
CREATE OBJECT lo_customer EXPORTING iv_name = lv_name.

Compliant ​

abap
DATA lo_customer TYPE REF TO cl_customer.
lo_customer = NEW #( iv_name = lv_name ).

Automated QuickFix ​

This rule provides an automated QuickFix directly in Eclipse ABAP Development Tools (ADT):

  1. Position the cursor on the flagged statement.
  2. Press Ctrl + 1 (Quick Assist).
  3. Select the automated refactoring to apply the clean syntax immediately.

Configuration & Thresholds ​

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

Parameter NameData TypeDefault Value
CHECK_CREATE_OBJECTBooleantrue
CHECK_RAISE_EXCEPTIONBooleantrue

Suppression ​

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

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

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

Technical Details ​

Released under the MIT License.