SAP CLEAR ABAP Statements



Get Example source ABAP code based on a different SAP table
  


ID CLEAR
• CLEAR ABAP Statement

CLEAR
Short Reference

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

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

What does it do?
Without the optional additions, dobj is assigned the type-dependent initial value. dobj is a result position, that is, either a variable or a writable expression can be specified.
Elementary data objects are assigned initial values in accordance with the tables of built-in ABAP types.
Enumerated variables are assigned to initial values in accordance with the elementary base type.
Reference variables are assigned the null reference.
Structures are set to their initial values component by component.
All lines of an internal table are deleted. The memory space required for the lines of the table is released except the initial memory requirement. The statement FREE can be used for releasing also the initial memory requirement if necessary.
The optional additions enable dobj to be filled with values other than the initial value.



Latest notes:

If dobj is an internal table with a header line, dobj[] must be specified to delete the lines, otherwise only the header line is deleted.
In the case of CLEAR, the initial memory request of an internal table is not released, which can have a positive effect on performance when inserting new lines in the internal table. The statement FREE is required only if as much memory as possible needs to be released.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
After initialization with CLEAR, the internal table itab no longer contains any lines.
ABEXA 00109
ABAP_EXAMPLE_END
• WITH CLEAR
• IN BYTE MODE CLEAR
• IN CHARACTER MODE CLEAR

ABAP Addition

What does it do?
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. val is a functional operand position. 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 this is not the case, a syntax error occurs, or a uncatchable exception is raised.



Latest notes:

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

ABAP_EXAMPLE_VX5
The byte string hexstring is assigned a specific byte value across the entire current length.
ABEXA 00110
ABAP_EXAMPLE_END



Runtime Exceptions


Non-catchable Exceptions
Reason for error:
Field val does not have length 1 for variant CLEAR fld WITH val IN BYTE MODE.
Runtime error:
CLEAR_VALUE_BYTEMODE_WRONG_LEN
Reason for error:
Field val does not have length 1 for variant CLEAR fld WITH val $[IN CHARACTER MODE$].
Runtime error:
CLEAR_VALUE_WRONG_LENGTH
ABAP_NONCAT_END

Return to menu