SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation → ABAP Programming Guidelines → Robust ABAP → Assignments, Calculations, and Other Types of Data Access →Runtime Errors When Accessing Data Objects
Background
Using data objects can cause runtime errors if the data object contains unsuitable content or the access to the data object is unsuitable. Examples:
Rule
Preventing Runtime Errors When Accessing Data Objects
You need to prevent runtime errors that can occur when accessing data objects. Robust applications should always be programmed to avoid these errors.
Details
If it not possible to determine by filling data objects appropriately whether subsequent access causes errors, then either the relevant properties must be checked before data access or possible exceptions (subclasses of CX_SY_CONVERSION_ERROR or CX_SY_DATA_ACCESS_ERROR) must be caught during data access.
Bad Example
The following source code illustrates a typical situation that can easily cause a runtime error if the subarea defined by offset and length is not defined in text.
Good Example
The following two source codes illustrate how the above example can be changed to avoid runtime errors using prevention or exception handling.