2011 Oct 25 10:00 AM
Hi All,
I have a problem in appending data from one field symbols to another field symbols.
<Field-symbols> :<f1> type any,
<f2> type any.
In program i am assing a table data to <f1> and <f2>.
Now i want to append <f2> to <f1>.
I have tried like this Append <f2> to <f1>.
But it's not working.
Can any boby suggest me how to acheive this.
Thanks in advance
Viswa
2011 Oct 25 10:11 AM
Hi
The problem is the defination of the field-symbol, one has to be a table:
FIELD-SYMBOLS: <WORKAREA> TYPE ANY.
FIELD-SYMBOLS: <INTTABLE> TYPE TABLE.
APPEND <WORKAREA> TO <INTTABLE>.
But before using the code above you need to assign them
Max
2011 Oct 25 10:11 AM
Hi
The problem is the defination of the field-symbol, one has to be a table:
FIELD-SYMBOLS: <WORKAREA> TYPE ANY.
FIELD-SYMBOLS: <INTTABLE> TYPE TABLE.
APPEND <WORKAREA> TO <INTTABLE>.
But before using the code above you need to assign them
Max
2011 Oct 25 10:44 AM
HI Max ,
Thanks for your suggession.
I have written as below.
FIELD-SYMBOLS: <fs_table> TYPE any TABLE,
<fs_table1> TYPE any TABLE,
<ls_table> TYPE any.
LOOP at <fs_table1> ASSIGNING <ls_table>.
APPEND <ls_table> to <fs_table>.
ENDLOOP.
But i am getting the below error while doing the same.
You cannot use explicit or implicit index operations on tables with types "HASHED TABLE" or "ANY TABLE". "<FS_TABLE>" has the type "ANY TABLE". .
Please help me to resolve the above error.
Thanks
Viswa
2011 Oct 25 10:53 AM
Then use type table instead of type any table
FIELD-SYMBOLS: <fs_table> TYPE TABLE,
<fs_table1> TYPE TABLE,
<ls_table> TYPE any.
2011 Oct 25 10:58 AM
Hi
If you want to use APPEND, that means you need to elaborate a standard table so don't use ANY TABLE, but TABLE only:
FIELD-SYMBOLS: <FS_TABLE> TYPE TABLE,
<FS_TABLE1> TYPE TABLE,
<LS_TABLE> TYPE ANY.
LOOP AT <FS_TABLE1> ASSIGNING <LS_TABLE>.
APPEND <LS_TABLE> TO <FS_TABLE>.
ENDLOOP.
If your table can be a STANDARD, SORTED or HASHED table, you need to use ANY TABLE in your definition, but you need to use INSERT to append the record:
FIELD-SYMBOLS: <FS_TABLE> TYPE ANY TABLE,
<FS_TABLE1> TYPE ANY TABLE,
<LS_TABLE> TYPE ANY.
LOOP AT <FS_TABLE1> ASSIGNING <LS_TABLE>.
INSERT <LS_TABLE> INTO TABLE <FS_TABLE>.
ENDLOOP.
Max
2011 Oct 25 11:39 AM
2011 Oct 25 10:16 AM
Don't define field symbol for internal table with TYPE ANY but with TYPE ANY TABLE, then you will be allowed to use some APPEND <structure> to <itab> or APPEND LINES OF <itab1> to <itab2>.
Regards,
Raymond
2011 Oct 25 11:18 AM
hi,
you can not used append with field symbols rather than use it assign.
fIELD-SYMBOLS: <fs_table> TYPE any TABLE,
<fs_table1> TYPE any TABLE,
<ls_table> TYPE any.
LOOP at <fs_table1> ASSIGNING <ls_table>.
ASSIGN <ls_table> to <fs_table>.
ENDLOOP.
2011 Oct 25 11:20 AM
hi,
you can not used append with field symbols rather than use it assign.
fIELD-SYMBOLS: <fs_table> TYPE any TABLE,
<fs_table1> TYPE any TABLE,
<ls_table> TYPE any.
LOOP at <fs_table1> ASSIGNING <ls_table>.
ASSIGN <ls_table> to <fs_table>.
ENDLOOP.
regards,
<removed by moderator>
Edited by: Thomas Zloch on Oct 25, 2011 12:47 PM
2011 Oct 25 11:36 AM
Hi
You have written:
you can not used append with field symbols rather than use it assign.
Why? Are you sure?
fIELD-SYMBOLS: <fs_table> TYPE any TABLE,
<fs_table1> TYPE any TABLE,
<ls_table> TYPE any.
LOOP at <fs_table1> ASSIGNING <ls_table>.
ASSIGN <ls_table> to <fs_table>.
ENDLOOP.
The code above will generate a dump at run time, because it can assign a flat structure (<LS_TABLE>) to a deep one (<FS_TABLE>).
You need also considere the ASSIGN is only a ponter, that means you'll have several fields symbols poiting to the same variable, it doesn't make a sense, fi it needs to elaborate 2 dinstict obetcs, so to fill 2 internal table.
In generally it can use all abap statament with field-symbols, of course it needs to make sure to assign it before using it
Max