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

Free itab functionality?

naveen_inuganti2
Active Contributor
0 Likes
1,984

Hi....

In which situation , we hav go for FREE syntax..?

Where this statement mandatory to use...?

What this statemnet exatly do..?

> free itab.

( Expecting practical answer, no links or documentaion )

Thanks,

Naveen.I

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,808

Hi,

free itab.

means it will free the memory space created for the variable.

16 REPLIES 16
Read only

bpawanchand
Active Contributor
0 Likes
1,808

Hi

Free is used to delete the enitire internal table with its data and it memory is given back to SAP or OS.

You can use FREE to initialize an internal table and release its memory space without first using the REFRESH or CLEAR statement. Like REFRESH, FREE works on the table body, not on the table work area. After a FREE statement, you can address the internal table again. 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.

DATA: BEGIN OF LINE,

COL1,

COL2,

END OF LINE.

DATA ITAB LIKE TABLE OF LINE.

LINE-COL1 = 'A'. LINE-COL2 = 'B'.

APPEND LINE TO ITAB.

REFRESH ITAB.

IF ITAB IS INITIAL.

WRITE 'ITAB is empty'.

FREE ITAB.

ENDIF.

Regards

Pavan

Read only

Former Member
0 Likes
1,808

free itab.

will release the memory which is allocated to itab.

Read only

0 Likes
1,808

Hi....Vijay...

So if i write

> free itab

before the select statement, My select statement should not work... isn't it?

Thanks,

Naveen Inuganti

Read only

Former Member
0 Likes
1,808

<content removed by moderator as it was just a copy and paste without giving a source>

With luck,

Pritam.

Edited by: Mike Pokraka on Aug 4, 2008 2:43 PM

Read only

Former Member
0 Likes
1,808

Hi,

with FREE statement we free the memory allocated by an internal table

Read only

Former Member
0 Likes
1,808

hiii

it will relese memory occupied by that internal table..and will make it available for another use.

select statement will not work in this case..because you need to define internal table with that structure before using select query and after using FREE statement.

regards

twinkal

Read only

0 Likes
1,808

Hi.. Twinkal....

But Iam getting output list for this code...

>data: itab like ztable occurs 0 with header line.

>

>free itab.

>

>select * from ztable into corresponding FIELDS OF TABLE itab.

>

>loop at itab.

> write:/ itab-zfield.

>endloop.

Please let me know what is the purpose of free itab.. and if it will deallocates memory of itab.. why my above code giving output...

Also... where this FREE itab statement is mandatory.....

Hi Amit...

It is some what confusing for me every time.... Thats why i posted this question....i tried with F1....

i.e...,

> The FREE statement has the same effect as the CLEAR

> ....

> FREE has the same effect as the REFRESH statement....

Sorry to say this its confusing for me.. Amit...

And thank you very much for your attention...

Plz clear my doubt....

Thanks,

Naveen Inuagti

Read only

Former Member
0 Likes
1,808

Press F1 on Key word and use SAP help.dont forget we are paying high buks them.

may be sometime we mis concept but SAP never

Read only

Former Member
0 Likes
1,809

Hi,

free itab.

means it will free the memory space created for the variable.

Read only

0 Likes
1,808

Hi,

FREE statement is very usefull when you want to de allocate the momory that has been used by variable or Internal tables.

Raghav

Read only

0 Likes
1,808

Hi Ragavedhar and Manjari...

Thanks for ur attention...

Plz check my second reply for this thread...

Thanks,

Naveen Inuganti.

Read only

0 Likes
1,808

Hi

data: itab like table occurs 0 with header line.

free itab.

*select * from ztable into corresponding FIELDS OF TABLE itab.*

loop at itab.

write:/ itab-zfield.

endloop.

What is confusing you see Internal table is Dynamic I mean

check this statement

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.

that means when in the select query as soon as you are trying to fill the itab then dynamically again the memory is assigned to it

The FREE statement has the same effect as the CLEAR

....

FREE has the same effect as the REFRESH statement....

this means that apart from INITIALIZING the internal table to its default values it will even de-allocates the memory.

And more over REFRESH is applied to only to teh body of teh internal table not to the header line.

Regards

Pavan

Read only

0 Likes
1,808

Hi.... Pavan....

So If i Write free itab statement it will deallocates memory in application server...

again that memory will allocate dynamically with the select statement...

So...

Better to use Free itab syntax.. at the end of the all reports (after displaying iatb with write statement or somthing) to reduce the allocated memory area for internal tables in the application server...

Is n't it?

Thanks,

Naveen Inuganti.

Read only

0 Likes
1,808

table t with header line:

clear t deletes the header line

refresh t deletes the table content (initial value remains)

clear t[] deletes the table content (modern version of refresh)

free t deletes both (initial value remains)

table t without header line:

clear t[] deletes the table content (initial value remains)

refresh t same result as before

free t same result as before

free releases some more ressources, which I don't know exactly.

Read only

0 Likes
1,808

HI

To make you correct it is not application server it is ABAP memory as soon you write FREE and more over see to be more precise FREE is used if at all you come across a situation where you have to read the data from a table based on two different conditions so first time you will read teh data and then you FREE the memory for Performance issues and again you read the data into internal table based on the second condition.

Regards

pavan

Read only

0 Likes
1,808

Ok pavan thank you very much...

Naveen Inuganti.