Application Development 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: 

doubt on CLEAR or REFRESH with FIELDSYMBOLS

Former Member

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.

1 ACCEPTED SOLUTION

Former Member

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

4 REPLIES 4

former_member194669
Active Contributor
0 Kudos

Hi,

Try with


unassign : <grr_ptr1>.

former_member156446
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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

Former Member

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