03-16-2010 2:51 PM
H all.
I have an inernal table itab declared as itab type standard table
This table has some records . Now i have declared an internal table with field symbol
field-symbols : <it_tab> type standard table ,
<ls_tab> type any.
loop at itab assigning <ls_tab>.
append <ls_tab> to <it_tab>.
endloop.
I am trying to copy the content of the table itab into internal table <it_tab> . System is going for dump.
Any help would be appreciated.
Best Regards
03-16-2010 3:50 PM
Hari,
Field symbols are not used as a mean of data transport b/w tables. Generally field symbols are used to "point" to some data in certain area.
"here you tell the system: let <ls_tab> "point" to values of particular row
loop at itab assigning <ls_tab>.
For statement..
append <ls_tab> to <it_tab>.
...<it_tab> is empty ("points" to nothing) you simply can't append anything to it.
As previous speakers told you: you need a table to be assing first to it.
So you create another table say itab2. Then with the following...
assign itab2 to <it_tab>. "....you tell the system: let <it-tab> "point" to all records of table itab2
Now you can "move" data b/w those two tables (itab2 to <it_tab> which is "pointitng" to itab2). Here however phisicall data trasnport takes place only b/w tables, no work area is used to transport rows of values, our field symbol <ls_tab> only "points" which row you want to trasnport from itab to itab2.
Hope this is more clear now
Marcin
03-16-2010 3:03 PM
You should first assign something to <it_tab>. Field symbols are just only pointers. If you want to proccess data of itab with <it_tab> fields symbol try something like this
assign itab to <it_tab>.
03-16-2010 3:27 PM
Hi Gtren,
If I do
assign itab to <it_tab>.
Then both will be refering the same data, change in data of a particular table will be refelected in the other.
Best regards
03-16-2010 3:30 PM
Hi
Just create ANOTHER internal table same as itab and assign your field symbol to that one .
All the changes will be only on other table.
At the end refer to that table instesd of your original itab
Best Regards
Yossi
03-16-2010 3:49 PM
Hi Hari,
A change in the Internal Table will be reflected in the Field Symbol Internal Table.
Have a look at the code below :
DATA : lt_scarr type STANDARD TABLE OF scarr.
data : ls_scarr TYPE scarr.
FIELD-SYMBOLS : <fs_lt_scarr> TYPE STANDARD TABLE,
<fs_ls_scarr> TYPE any.
*create DATA
data : count TYPE i VALUE 1.
SELECT * FROM scarr into TABLE lt_scarr.
ASSIGN lt_scarr to <fs_lt_scarr>.
ls_scarr-carrid = 'XX'.
MODIFY lt_scarr FROM ls_scarr INDEX 1.
LOOP AT lt_scarr ASSIGNING <fs_ls_scarr>.
IF count = 30.
exit.
else.
count = count + 1.
ENDIF.
APPEND <fs_ls_scarr> to <fs_lt_scarr>.
ENDLOOP.
Hope this helps.
Thanks,
Samantak.
03-16-2010 3:03 PM
Hi,
<it_itab> is a field-symbol (which can point to an internal table), not the internal table.
You can not append rows to it before assigning any table to this field-symbol.
Please refer to the documentation.
Regards,
--
Przemysław
03-16-2010 3:50 PM
Hari,
Field symbols are not used as a mean of data transport b/w tables. Generally field symbols are used to "point" to some data in certain area.
"here you tell the system: let <ls_tab> "point" to values of particular row
loop at itab assigning <ls_tab>.
For statement..
append <ls_tab> to <it_tab>.
...<it_tab> is empty ("points" to nothing) you simply can't append anything to it.
As previous speakers told you: you need a table to be assing first to it.
So you create another table say itab2. Then with the following...
assign itab2 to <it_tab>. "....you tell the system: let <it-tab> "point" to all records of table itab2
Now you can "move" data b/w those two tables (itab2 to <it_tab> which is "pointitng" to itab2). Here however phisicall data trasnport takes place only b/w tables, no work area is used to transport rows of values, our field symbol <ls_tab> only "points" which row you want to trasnport from itab to itab2.
Hope this is more clear now
Marcin