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: 

Read Dynamic Field Symbol

Former Member
0 Kudos

Hello ,

I have a field symbol where i am not aware of fields (Column Name) , i mean column names are Dynamic.

Problem is i need to read this field symbol value , how can i do it . It will always have 1 record

Example

Field Symbol looks something like this

<FS> Column Name dynamic -


>

A B C

Record

1 2 3

So now i have to refer to Second Column (i.e. is B in this case) , how should i do

What i tried .

1. <FS>-(Column Name in variable in brackets) - It doesnt work , Error Message unable to interpret the number B

2. <FS>[1] - Error out.

1 ACCEPTED SOLUTION

hymavathi_oruganti
Active Contributor
0 Kudos

use ASSSIGN COMPONENT statement

and ASSIGN statement

FIELD-SYMBOLS: <FS1>, <FS2>.

loop at itab.

ASSIGN COMPONENT (COLUMN NAME / INDEX) OF ITAB TO <FS1>.

ASSIGN (VALUE) TO <FS2>.

<FS1> = <FS2>.

ENDLOOP.

5 REPLIES 5

hymavathi_oruganti
Active Contributor
0 Kudos

use ASSSIGN COMPONENT statement

and ASSIGN statement

FIELD-SYMBOLS: <FS1>, <FS2>.

loop at itab.

ASSIGN COMPONENT (COLUMN NAME / INDEX) OF ITAB TO <FS1>.

ASSIGN (VALUE) TO <FS2>.

<FS1> = <FS2>.

ENDLOOP.

Former Member
0 Kudos

Rajiv,

It doesn't work like that.

This is what you will have to do.

field-symbols : <fs_any> type any

ASSIGN COMPINENT 'COLUMN1' OF STRUCTURE <fs> TO <fs_Any>.

Now, <fs_any> will have the value of the column, you will have to do this for all the columns.

Regards,

Ravi

Note : Please mark the helpful answers

Former Member
0 Kudos

For a structured data object <s>, you can use the statement

<b>

ASSIGN COMPONENT <comp> OF STRUCTURE <s> TO <FS>.

</b>

to assign one of its components <comp> to the field symbol <FS>. You can specify the

component <comp> either as a literal or a variable. If <comp> is of type C or a structure which

has no internal tables as components, it specifies the name of the component. If <comp> has any

other elementary data type, it is converted to type I and specifies the number of the component.

In the assignment is successful, SY-SUBRC is set to 0. Otherwise, it returns 4.

athavanraja
Active Contributor
0 Kudos

if you know the column position you can use like below.

assign component 2 of structure <sorucefs> to <targetfs>.

Regards

Raja

Former Member
0 Kudos

Thanks everyone ... Got lost with Field Symbols .

Rajiv Gupta