Application Development and Automation 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: 
Read only

field symbols : syntax error

Former Member
0 Likes
1,004

TYPES: BEGIN OF NAME,

FIRSTNAME(10),

LASTNAME(10),

END OF NAME.

data : person1 type standard table of name with header line.

start-of-selection.

person1-firstname = 'Shiv'.

person1-lastname = 'Kasthala'.

append person1.

clear person1.

FIELD-SYMBOLS <fs> TYPE table.

assign person1 to <fs>.

This sample code gives me a syntax error that person1 and <fs> are in-compatible. Can anybody please suggest me the reason why?

Also, can some body guide me to some documentation where I can use dynamic programming in daily ABAP.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
930

try this code

data: BEGIN OF person1 occurs 0,

FIRSTNAME(10),

LASTNAME(10),

END OF person1.

start-of-selection.

person1-firstname = 'Shiv'.

person1-lastname = 'Kasthala'.

append person1.

clear person1.

FIELD-SYMBOLS <fs> TYPE any table.

assign person1[] to <fs>.

In your code person1 is assigned to field symbol which has only work area not entire table.

7 REPLIES 7
Read only

Former Member
0 Likes
931

try this code

data: BEGIN OF person1 occurs 0,

FIRSTNAME(10),

LASTNAME(10),

END OF person1.

start-of-selection.

person1-firstname = 'Shiv'.

person1-lastname = 'Kasthala'.

append person1.

clear person1.

FIELD-SYMBOLS <fs> TYPE any table.

assign person1[] to <fs>.

In your code person1 is assigned to field symbol which has only work area not entire table.

Read only

Former Member
0 Likes
930

hi, no need to do any change, only replace one line as following:

replace

ASSIGN PERSON1 TO <FS>.

with

ASSIGN person1[] to <fs>.

the compile failure due to person1 has header line.

<FS> is table type.

So compiler treat 'assign person1 to <fs>.' as header line assigned to a table type field symbol.

So it failed.

thanks

Read only

Former Member
0 Likes
930

hi,

person1 is of type standard table,

define

field-symbol <fs> type standard table of name.

try this, may be this will work.

regards,

manohar.

Read only

Former Member
0 Likes
930

Ok. So, now how can I get the contents of a field symbol on the screen if the field symbol is of type "standard table".

Read only

0 Likes
930

see below code, its the same code but I have added one more workarea called person and I assigned from field symbol and printed.

data: BEGIN OF person1 occurs 0,

FIRSTNAME(10),

LASTNAME(10),

END OF person1.

data: BEGIN OF person,

FIRSTNAME(10),

LASTNAME(10),

END OF person.

start-of-selection.

person1-firstname = 'Shiv'.

person1-lastname = 'Kasthala'.

append person1.

clear person1.

FIELD-SYMBOLS <fs> TYPE any table.

assign person1[] to <fs>.

loop at <fs> into person.

write : / person-firstname, person-lastname.

endloop.

Read only

0 Likes
930

Thanks Satyanarayana, I have awardded you points for that. Just one more thing:

1. Can you tell me how & where can i use field symbols in daily ABAP programming. As such I m not able to find any use to it.

Example: Can it be used to display the internal table contents of any internal table declared in a program irrespective of its structure.

Read only

0 Likes
930

Yes, there are a couple uses for field symbols. One that comes to mind, is when working with dynamic internal tables and structures.

Check out this weblog.

/people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap

Regards,

Rich Heilman