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: 

Assign field symbols

Former Member
0 Kudos

Hi,

I have an issue on

FIELD-SYMBOLS :

<itab> TYPE ANY TABLE ,

<wa> TYPE ANY,


I am facing assign error.

How to append values into internal table from WA using field symbols.??

5 REPLIES 5

former_member156446
Active Contributor
0 Kudos

APPEND INITIAL LINE TO <ITAB> assigning <wa>.

<wa>-field1 = value1.

<wa>-field2 = value2.

0 Kudos

Hi jay,

I have declared ITAB as type ANY so the above statement will give error.

Thanks

VIjay

0 Kudos

This worked for me:

FIELD-SYMBOLS: <itab> TYPE STANDARD TABLE,
               <wa>   TYPE any.

APPEND INITIAL LINE TO <itab> ASSIGNING <wa>.

sandroramos
Active Participant
0 Kudos

Hi Vijay,

Field symbols are symbolic names for existing data objects, so you must have an internal table assigned to <itab>, for example:

DATA: lt_ekko TYPE STANDARD TABLE OF ekko,

           lt_ekpo TYPE STANDARD TABLE OF ekpo.

FIELD-SYMBOLS: <itab> TYPE STANDARD TABLE.

DO 2 TIMES.

     CASE SY-INDEX.

          WHEN 1.

               ASSIGN lt_ekko TO <itab>.

          WHEN 2.

               UNASSIGN <itab>.

               ASSIGN lt_ekpo TO <itab>.

     ENDCASE.

ENDDO.

Please, Let me know if i was helpful.

Regards,

Sandro Ramos

former_member188458
Active Participant
0 Kudos

HI Vijay ,

Field symbols are nothing but pointers .

Further if you have declared it as type any table , it is important that you first assign a type to it .

and you assign the type to field symbol at design time or at run time .

e.g.  For run time , below is the sample code

data : lv_type_name type char4 value 'MARA'.

data : lo_ref type data .

field-symbols : <lt_table> type any table,

                          <ls_data> type any .

create data  lo_ref type standard table of  ( lv_type ).

assign lo_ref->* to <lt_table> .""once u do this <lt_table> has type assigned

append initial line to <lt_table> assigning <ls_data>.

Hope this solves your issue.

Best Regards,

Rini