Start of Content Area

Resetting Variables to Their Initial Value  Locate the document in its SAP Library structure

To reset a variable var to the appropriate initial value for its type, use the statement

CLEAR var.

This statement has different effects for different data types:

·        Elementary ABAP types

The CLEAR statement sets the value of elementary variables to their initial value (see the keyword documentation) not to the start value, which is set using the VALUE parameter of the DATA statement.

·        References

The CLEAR statement resets a reference variable to its initial value, that is, so that it does not point to an object.

·        Structures

The CLEAR statement resets the individual components of a structure to their respective initial values.

·        Internal tables

The CLEAR statement deletes the entire contents of an internal table (see also Initializing Internal Tables).

You cannot use the CLEAR statement to reset a constant.

Example

REPORT demo_data_clear.

DATA number TYPE i VALUE '10'.

WRITE number.

CLEAR number.

WRITE / number.

The output appears as follows:

        10

     0

The CLEAR statement resets the contents of the field number from 10 to its initial value 0.

 

End of Content Area