MOVE_CAST_ERROR

medium

Type Cast Failed — Value Incompatible With Target Type

Module: ABAP OO

What this means

MOVE_CAST_ERROR fires when an explicit type cast in ABAP OO fails at runtime. When code uses MOVE ... ?TO ... (down-cast) or the cast operator CAST, the runtime checks whether the actual object type is compatible with the target reference type. If it is not — for example, casting a CL_BASE reference that at runtime holds a CL_SUBCLASS_A instance to CL_SUBCLASS_B — the cast fails with MOVE_CAST_ERROR. This is a design issue: the code assumes a more specific type than the actual runtime object.

Recommended Fix

Before performing a down-cast, use IS INSTANCE OF to verify the actual runtime type: IF lo_obj IS INSTANCE OF cl_target. Cast inside the IF block. Alternatively use TRY/CATCH with CX_SY_MOVE_CAST_ERROR. Review SE24 to understand the class hierarchy and determine whether the cast assumption is architecturally correct.

Quick Info

ModuleABAP OO
Severitymedium
Diagnose in
ST22SE24