01-29-2008 6:32 PM
hi ,
i wrote code as
loop at <grr_ptr> assigning <grr_ptr1>.
................
...........
clear <grr_ptr1>.
endloop.
when iam saying clear the internal table is getting empty. when i use refresh with <grr_ptr1>, it is saying it is not a workarea.
I have taken both <grr_ptr> and <grr_ptr1> as type any.
how to solve it.
01-29-2008 10:24 PM
Hi Ramana,
Field symbols are sort of pointers (and not pointers) to a data object in memory. When you clear the field symbol
using CLEAR statement, the data object that is being pointed to by the field symbol is cleared/initialised. If the real intent was
to clear the field symbol, then UNASSIGN statement should be used which will clears the content assigned to the
field symbol using ASSIGNING addition. This content is the memory address of the data object and not the data
object itself.
See below:
field-symbols: <grr_ptr> type any,
<grr_ptr1> type any.
loop at <grr_ptr> assigning <grr_ptr1>. "here <grr_ptr1> is assigned with the current row of the loop
................
...........
CLEAR <grr_ptr1>. " this will clear the data object i.e. the current row of the internal table
UNASSIGN <grr_ptr1>. "this will clear the content of the <grr_ptr1> i.e. the memory address of the data object
endloop.
"if you don't use the UNASSIGN statement above, after the endloop statement, the internal table will still have rows but they are all initialised.
The reason you are getting error for using REFRESH statement is that you are trying to refresh a row (the data
object assigned to <grr_ptr1>) and not a table though the field symbol was defined to point to any object ( TYPE ANY ).
Hope this helps.
Thanks
Sanjeev
01-29-2008 6:35 PM
01-29-2008 6:53 PM
Hi Ramana
Field symbol is not a value holding area.. its a pointer which points towards the main memory...
itab is a table.
field-symbols: <fs> type itab.
assign <fs> to <fs1> "<<< assigns the content
unassign <fs1> "<<< clears the content
now any changes you make to <fs> will automatically reflect the itab.. no need to even use modify statement also...
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Jan 29, 2008 1:54 PM
01-29-2008 7:18 PM
HI,
As Field Symbols points to the memory, If we clear Field Symbols it will delete the entery from internal table. So we don't need the Clear statements with Fiel Symbols.
Thanks
01-29-2008 10:24 PM
Hi Ramana,
Field symbols are sort of pointers (and not pointers) to a data object in memory. When you clear the field symbol
using CLEAR statement, the data object that is being pointed to by the field symbol is cleared/initialised. If the real intent was
to clear the field symbol, then UNASSIGN statement should be used which will clears the content assigned to the
field symbol using ASSIGNING addition. This content is the memory address of the data object and not the data
object itself.
See below:
field-symbols: <grr_ptr> type any,
<grr_ptr1> type any.
loop at <grr_ptr> assigning <grr_ptr1>. "here <grr_ptr1> is assigned with the current row of the loop
................
...........
CLEAR <grr_ptr1>. " this will clear the data object i.e. the current row of the internal table
UNASSIGN <grr_ptr1>. "this will clear the content of the <grr_ptr1> i.e. the memory address of the data object
endloop.
"if you don't use the UNASSIGN statement above, after the endloop statement, the internal table will still have rows but they are all initialised.
The reason you are getting error for using REFRESH statement is that you are trying to refresh a row (the data
object assigned to <grr_ptr1>) and not a table though the field symbol was defined to point to any object ( TYPE ANY ).
Hope this helps.
Thanks
Sanjeev