When use Clear, Refresh or Delete in ABAP variable?
In ABAP, memory management is handled through various commands: FREE: This command deallocates the memory assigned to a variable, making the memory available for other uses. After this, the variable is no longer usable in the current program. REFRESH: This is used for clearing all entries from an internal table while retaining the memory allocation, allowing the table to be reused within the same program. CLEAR: It empties the content of a variable without releasing the allocated memory, leaving it available for further use. DELETE: This command removes specific values from a table or variable based on a given condition.

Then the compiler ABAP will allocate memory (With memory ID 433443
) equal to size 1 character size.
DATA : l_Variable(1) type c
. l_Variable = 'X'
Then if you assign a value for the above l_Variable
the variable or memory ID 433443 contains this ‘X’ value.
If you write:
- FREE Variable. The memory allocated is refreshed and freed. Means after this statement the memory to the variable is no more. It is freed from the program and can be used for some other program are purpose.
- REFRESH i_tab. Used for table to clear all the entries from the internal table body. but sill memory allocation exist and you can use some other with in the program.
- CLEAR variable it clears the memory of the variable i.e. variable will be empty.
- DELETE variable or I_tab index i etc. It deletes a specific value from a I_tab body based on condition.