Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

clear

Former Member
0 Likes
1,417

Hi,

for a internal table without header line wht will the clear statement do?

regards,

kb

13 REPLIES 13
Read only

Former Member
0 Likes
1,386

Hi,

use this . itab is the internal table.

itab[].

regards,

Santosh Thorat.

Read only

Former Member
0 Likes
1,386

Hi,

if the header line is not available we cant do with the clear statement, if we want to remove the data of internal table at that time we use Clear itab[].

regards,

satish.

reward points.if it is useful.

Read only

Former Member
0 Likes
1,386

Hi ,

use the work area. clear the work area.

ex:

clear wa.

Regards,

S.Nehru

Read only

Former Member
0 Likes
1,386

Hi,

You can initialize internal tables with the:

CLEAR <itab>.

statement. This statement restores an internal table to the state it was in immediately after you declared it. This means that the table contains no lines. However, the memory already occupied by the memory up until you cleared it remains allocated to the table.

If you are using internal tables with header lines, remember that the header line and the body of the table have the same name. If you want to address the body of the table in a comparison, you must place two brackets ([ ]) after the table name:

CLEAR <itab>[].

Regards,

Bhaskar

Read only

Former Member
0 Likes
1,386

Hi,

In this case clear will clears the body of your internal table, pls test the below code.

types:

begin of x_mara,

matnr like mara-matnr,

end of x_mara.

data: t_mara type standard table of x_mara.

select matnr from mara into table t_mara.

clear t_mara.

if sy-subrc = 0.

endif.

Reward if useful.

Thanks,

Sreeram.

Read only

former_member386202
Active Contributor
0 Likes
1,386

Hi,

You have to use work area for without header line internal table. For that the statement is

CLEAR WA.

Regards,

PRashant

Read only

Former Member
0 Likes
1,386

hi,

Internal Tables without Header Line : Here there is no work area associated with the table. Work area is to be explicitly specified when we need to access such tables. Hence these tables cannot be accessed directly.

CLEAR statement has different effects for different data types:

· Elementary ABAP types

The CLEAR statement sets the value of elementary variables to their initial value (see the keyword documentation) not to the start value, which is set using the VALUE parameter of the DATA statement.

· References

The CLEAR statement resets a reference variable to its initial value, that is, so that it does not point to an object.

· Structures

The CLEAR statement resets the individual components of a structure to their respective initial values.

· Internal tables

The CLEAR statement deletes the entire contents of an internal table.

You cannot use the CLEAR statement to reset a constant.

Reward if helpful.

Thank you,

Regards.

Read only

Former Member
0 Likes
1,386

Hai,

If you declared an internal table without header line,

if you use clear statement:

It removes the all entries from that internal table.

So your internal table will be empty.

Read only

Former Member
0 Likes
1,386

hi,

without herader line the clear statement will clear the contents of the table. With header line clear will clear the header of the table.

Read only

Former Member
0 Likes
1,386

hi,

for a table with out headerline we cannot give clear statement as an internal table without headerline cannot have work areaso it wont be doing any thing

regards,

swaroop

Read only

Former Member
0 Likes
1,386

CLEAR statement initializes the object.

Now, if this object is a header line, the header line will be cleared or initialized.

If this object is a table, the tablw will be cleared. Table remains in the memory but will not have any data or lines.

Lets say an internal table itab is defined with a header line then itab refers to both the header line and the table (body) itself. In this case,

CLEAR itab. " this will clear the header line

By default itab refers to the header line, if there is one.

For clearing the table, we need to refer to the table (body). the reference to the table can be made using [] after the table name like:

CLEAR itab[]. "this will clear the table (body)

Now if the table itab is defined without header line there will be no other object than the table body itself to refer to. So, in this case:

CLEAR itab. " this will clear the table (body) as itab refers

"to only one object, table (body)

CLEAR itab[]. "this will clear the table (body)

It is better to stop defining internal tables with header line as this is obsolete in ABAP Objects context and this is going to be the rule eventually.

Hope this helps.

Thanks

Sanjeev

Read only

Former Member
0 Likes
1,386

thanks

Read only

0 Likes
1,386

Can you stop for a while please.

I have to open one thread in ABAP,and it is saying ABAP server is too busy ,try again later