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

clarification

Former Member
0 Likes
784

Hi,

Please check this,

**************************

APPEND it_itab.

CLEAR it_itab.

SORT it_itab.

**************************

If i give like this sorting will be done.

Please let me know.

Can i keep that clear statement in between them .

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
762

Only if your table has a header line, otherwise all records will be deleted. If you want to delete records from your table with header line use: clear itab[].

6 REPLIES 6
Read only

Former Member
0 Likes
763

Only if your table has a header line, otherwise all records will be deleted. If you want to delete records from your table with header line use: clear itab[].

Read only

Former Member
0 Likes
762

hi Ali,

No problem you can give it in that way as clear statement clears only the header of it_itab table ... but better sort the table with key fields of the table ..

i.e,

SORT ITAB BY MATNR.

Regards,

Santosh

Message was edited by:

Santosh Kumar Patha

Read only

Former Member
0 Likes
762

it will work fine as ur appending data to the internal table.

CLEAR statement doesnot clear data from internal table but just clears data from header line.

SORT statement will sort the records according to the fields of the internal table.

if u want to sort based on fields, use the field names in the sort statement.

Read only

Former Member
0 Likes
762

hi ali,

If ur internal table is with header line then u can use clear

if ur itab is without header then u cannot use CLEAR , this will refresh the whole body of the internal table ,in that case just use only REFRESH ITAB.

Read only

Former Member
0 Likes
762

Here is some helpful info

CLEAR itab.

The memory space required for the table is released, except for the initial memory requirement.

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 itself, not the header line, during initialization using CLEAR, you must place two square brackets ([]) after the table name.

CLEAR itab[].

To ensure that the table itself has been initialized, you can use the statement

REFRESH itab.

This always applies to the body of the table. With REFRESH, too, the initial memory requirement fort he table remains reserved. To release this memory space, use the statement

FREE itab.

You can use FREE to directly initialize an internal table and to release its entire memory space, including the initial memory requirement, without first using the REFRESH or CLEAR statements. Like REFRESH, FREEaccesses the table body, not the table work area. After a FREEstatement, the internal table still exists. It still occupies the amount of memory required for its header (currently 256 bytes). When you refill the table, the system has to allocate new memory space to the lines.

Regards,

Santosh

Read only

Former Member
0 Likes
762

Hi Ali,

APPEND it_itab Appends the record into the body of the internal table.

CLEAR it_itab clears the header line of the internal table.

SORT it_itab sorts the fields of the internal table.

But better use the Syntax

SORT < Int. Table> by <Field Name>.

Hope this resolves your query.

<b>Reward all the helpful answers.</b>

Regards