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: 

How to append one field symbol data to another field symbols.

Former Member
0 Kudos
3,568

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos
944

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

9 REPLIES 9

Former Member
0 Kudos
945

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

0 Kudos
944

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

0 Kudos
944

Then use type table instead of type any table


FIELD-SYMBOLS: <fs_table> TYPE TABLE,
                   <fs_table1> TYPE TABLE,
                   <ls_table> TYPE any.

0 Kudos
944

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

0 Kudos
944

Hi All,

Solved.

Thanks

Viswa

raymond_giuseppi
Active Contributor
0 Kudos
944

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

Former Member
0 Kudos
944

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.

Former Member
0 Kudos
944

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

0 Kudos
944

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