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

CLEAR  Syntax Diagram

Short 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-specific 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.

Note

If dobj is an internal table with a header line, dobj[] must be specified to delete the rows, otherwise only the header line will be deleted.

Addition

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

Effect

If the WITH val addition is used and CHARACTER or BYTE MODE specified, all spaces 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 dobj and val do not have the correct type and the correct length in a non- Unicode program, they are still handled appropriately regardless of the actual type. In Unicode programs, this produces a syntax error or raises a non-handleable exception.

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-Catchable Exceptions