CLEAR : ABAP Keyword a day
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.
———————
ABAPer, mail: abap.community@gmail.com http://www.erpdb.info
If you like this post, you may as well like these too:
- AT : ABAP Keyword a day AT Events in lists- AT LINE-SELECTION.- AT USER-COMMAND.- AT PFn.Events on selection screens- AT SELECTION-SCREEN.Control break with extracts- AT NEW f.- AT END OF f.- AT FIRST.- AT LAST.- AT...
- GET: ABAP Keyword a day GET: Event keyword for defining event blocks for reporting events. GET <node> [FIELDS <fi> <f 2>...]. GET node LATE [FIELDS f1 f2 ...]. Only occurs in executable programs. When the...
- DO : ABAP Keyword a day DO Variants 1. DO. 2. DO n TIMES. Variant 1 DO. Addition … VARYING f FROM f1 NEXT f2 Effect Repeats the processing enclosed by the DO and ENDDO statements...
- ASSIGN: ABAP Keyword a day ASSIGN Variants:1. ASSIGN f TO .2. ASSIGN (f) TO .3. ASSIGN TABLE FIELD (f) TO .4. ASSIGN LOCAL COPY OF MAIN TABLE FIELD (f) TO .5. ASSIGN COMPONENT idx OF...
- FORM: ABAP Keyword a day FORM: Defines a subroutine. Syntax FORM [USING ... [VALUE(][)] [TYPE |LIKE ]„. ] [CHANGING... [VALUE(][)] [TYPE |LIKE ]„. ]. Introduces a subroutine. The USING and CHANGING additions define the subroutine’s...
- FETCH : ABAP Keyword a day FETCH Basic form FETCH NEXT CURSOR c target. Effect Uses the cursor c to read the next line or lines from the dataset of a database table determined by OPEN...
- EXPORT : ABAP Keyword a day EXPORT 1 2 3 4 *Export data - EXPORT obj1 ... objn TO MEMORY. - EXPORT obj1 ... objn TO DATABASE dbtab(ar) ID key. - EXPORT obj1 ... objn TO...
- DIVIDE : ABAP Keyword a day DIVIDE Basic form DIVIDE n1 BY n2. Effect Divides the contents of n1 by n2 and places the result in n1 . This is equivalent to: n1 = n1 /...
- DESCRIBE : ABAP Keyword a day DESCRIBE Return attributes of a field - DESCRIBE FIELD f. Return attributes of an internal table - DESCRIBE TABLE itab. Determine distance between two fields - DESCRIBE DISTANCE BETWEEN f1...
- DATA : ABAP Keyword a day DATA Variants1. DATA f.2. DATA f(len).3. DATA: BEGIN OF rec,…END OF rec.4. DATA: BEGIN OF itab OCCURS n,…END OF itab.5. DATA: BEGIN OF COMMON PART c,…END OF COMMON PART.EffectDefines global...
- CONTINUE: ABAP Keyword a day CONTINUE Basic formCONTINUE.EffectWithin loop structures like * DO … ENDDO* WHILE … ENDWHILE* LOOP … ENDLOOP* SELECT … ENDSELECTCONTINUE terminates the current loop pass, returns the processing to the beginning...
- CONCATENATE : ABAP Keyword a day CONCATENATE Basic form CONCATENATE f1 … fn INTO g. Addition … SEPARATED BY h Effect Places the fields f1 to fn after g . With the fields fi (1 <=...
- COMPUTE: ABAP Keyword a day COMPUTEBasic formCOMPUTE n = arithexp.EffectEvaluates the arithmetic expression arithexp and places the result in the field n .Allows use of the four basic calculation types + , – , *...
- CASE: ABAP Keyword a day CASE Basic formCASE f. Effect Case distinction.Depending on the current contents of a field, this statement executes one of several alternative processing branches. The field whose contents determine how the...
- GET PARAMETER: ABAP Keyword a day GET PARAMETER Gets an SPA/GPA parameters. Syntax GET PARAMETER ID <pid> FIELD <field_name>. Writes the value of the SPA/GPA parameter <pid> from the user-specific SAP memory into the variable <f>....



















Extremely rated post. I be taught one thing totally new on completely different blogs everyday. Deciding on one . stimulating to read the paper content material from different writers and be taught slightly something from their website. I’d like to use sure of this content on my blog you’re mind. Natually I’ll give a hyperlink here we are at your web-site. Admire your sharing.