CLEAR (ABAP Keyword) introduction & details
CLEAR
Basic
form
CLEAR f.
Additions
1. ... WITH g
2. ... WITH
NULL
Effect
Resets the contents of f to its initial value.
For
predefined types (see DATA ), the following initial values are used:
Type C :
' ... ' (blank character) Type N : '00...0' Type D : '00000000' Type T :
'000000'
Type I : 0 Type P : 0 Type F : 0.0E+00 Type X : 0
If f is a field
string, each component field is reset to its initial value. If it is an internal
table without a header line, the entire table is deleted together with all its
entries. If, however, f is an internal table with a header line, only the
sub-fields in the table header entry are reset to their initial
values.
Example
DATA: TEXT(10) VALUE 'Hello',
NUMBER TYPE I
VALUE 12345,
ROW(10) TYPE N VALUE '1234567890',
BEGIN OF
PLAYER,
NAME(10) VALUE 'John',
TEL(8) TYPE N VALUE '08154711',
MONEY
TYPE P VALUE 30000,
END OF PLAYER.
...
CLEAR: TEXT, NUMBER,
PLAYER.
The field contents are now as follows:
ROW =
'1234567890'
TEXT = ' '
NUMBER = 0
PLAYER-NAME = ' '
PLAYER-TEL =
'00000000'
PLAYER-MONEY = 0
Notes
When CLEAR references an internal
table itab with a header line, it only resets the sub-fields in the header entry
to their initial values (as mentioned above). The individual table entries
remain unchanged.
To delete the entire internal table together with all its
entries, you can use CLEAR itab[] or REFRESH itab . Here, a Note is still
required to explain how to manipulate tables with/without header
lines.
Within a logical expression , you can use f IS INITIAL to check that
the field f contains the initial value appropriate for its type.
Variables
are normally initialized according to their type, even if the specification of
an explicit initial value (addition " ... VALUE lit " of the DATA statement) is
missing. For this reason, it is not necessary to initialize variables again with
CLEAR after defining them.
Addition 1
... WITH g
Effect
The
field f is filled with the value of the first byte of the field g
.
Addition 2
... WITH NULL
Effect
Fills the field with
hexadecimal zeros.
Note
You should use this addition with particular
care because the fields of most data types thus receive values which are really
invalid.
Note
Performance
CLEAR requires about 3 msn (standardized
microseconds) of runtime to process a field of type C with a length of 10 and
about 2 msn to process a field of the type I. To delete an internal table with
15 fields, it needs about 5 msn.
Related 10 ABAP Syntax Tutorials
Most readed SAP Tutorials
- WRITE - Output to a list ( SAP ABAP Keyword)
WRITE ( Output to a list ) is a keyword used in SAP ABAP programming.This tutorial covers its introduction & syntax details. - List of SAP HR TABLES and Infotypes tables
Detailed full list of tables and infotypes used in SAP HR module. - List of SAP MM Transaction codes
This documentation covers the details of SAP MM Transaction codes - SELECT-OPTIONS ( SAP ABAP Keyword)
SELECT-OPTIONS is a keyword used in SAP ABAP programming.This tutorial covers its introduction & syntax details. - FI Accounts Receivable and Accounts Payable | SAP FI PDF manual
The following topics are an introduction to the Accounts Receivable and Accounts Payable application components. - SAP MM Process Flow
The typical procurement cycle for a service or material consists of the following phases: - SELECT clause ( SAP ABAP Keyword)
SELECT clause is a keyword used in SAP ABAP programming.This tutorial covers its introduction & syntax details.
Latest Added SAP documents
- 9KE9 Transaction code
Details about SAP transaction code 9KE9 - 9KE8 Transaction code
Details about SAP transaction code 9KE8 - 9KE7 Transaction code
Details about SAP transaction code 9KE7 - 9KE6 Transaction code
Details about SAP transaction code 9KE6 - 9KE5 Transaction code
Details about SAP transaction code 9KE5 - 9KE4 Transaction code
Details about SAP transaction code 9KE4 - 9KE3 Transaction code
Details about SAP transaction code 9KE3 - 9KE2 Transaction code
Details about SAP transaction code 9KE2 - 9KE1 Transaction code
Details about SAP transaction code 9KE1 - 9KE0 Transaction code
Details about SAP transaction code 9KE0