ABAP - Keyword Documentation →  ABAP - Reference →  Processing Internal Data →  Assignments →  Initializations → 

CLEAR

Quick Reference

Syntax

CLEAR dobj [ {WITH val [IN {CHARACTER|BYTE} MODE] }
           | {WITH NULL} ].


Addition:

... WITH val [IN {CHARACTER|BYTE} MODE]

Effect

Without the optional additions, dobj is assigned the type-friendly initial value. In the case of dobj, this is a result position, which means either a variable or a writable expression ´can be specified.

The optional additions enable dobj to be filled with values other than the initial value.

Notes

Addition

... WITH val [IN {CHARACTER|BYTE} MODE]

Effect

If the addition WITH val is used and CHARACTER or BYTE MODE specified, all places in dobj are replaced either with the first character or the first byte in val. In val a functional operand position is involved. If dobj is of the type string or xstring, the string is processed in its current length.

If the MODE addition is not specified, the addition IN CHARACTER MODE applies. Depending on the addition, the data object dobj must be either character-like or byte-like. Depending on the addition, the operand val must be character-like or byte-like and have the length 1. If not, a syntax error occurs or a non-handleable exception is raised.

Note

If the obsolete addition WITH NULL is used, all bytes of a flat data object can be replaced by hexadecimal 0 outside classes.

Example

The byte string hexstring as assigned a specific byte value over the entire current length.

DATA: hexstring TYPE xstring,
      hex       TYPE x LENGTH 1 VALUE 'FF'.
...
hexstring = '00000000'.
...
CLEAR hexstring WITH hex IN BYTE MODE.

Exceptions

Non-Handleable Exceptions