CLEAR

Short Reference

Syntax

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


Extras:

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

2. ... WITH NULL

Effect

Without the optional additions, the data object dobj is assigned the type-specific initial value. The following applies:

The optional additions allow you to fill the spaces of a data object with other values than the initial value.

Note

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

Addition 1

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

Effect

If you use the WITH val addition and specify BYTE or CHARACTER MODE, all spaces are replaced either with the first byte or the first character in val. If dobj is of the type string or xstring (as of Release 6.10), the string is processed in its current length.

The IN BYTE and CHARACTER MODE additions can be used as of Release 6.10 (see also Processing Byte Strings and Character Strings). Without specification and before Release 6.10 the IN CHARACTER MODE addition applies. Depending on the addition, the data object dobj must be either byte-type or character-type and the data object val must be either byte-type or character type and have the length 1. Before Release 6.10, dobj and val must be flat. If dobj and val do not have the correct type and correct length in a non- Unicode program, they are still handled as if they do, independently of the actual type. In Unicode programs, this will cause a Syntax error or an exception that cannot be handled.

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.

Addition 2

... WITH NULL

Effect

This addition, which is not allowed in ABAP Objects, replaces all bytes of dobj with the value hexadecimal 0. In this case, the data object dobj must be flat.

Note

The WITH NULL addition should only be used for byte-type data objects and therefore be replaced with the CLEAR WITH val addition, which - in this context - at least ensures a higher level of security in Unicode programs.

Exceptions

Non-Catchable Exceptions