04-17-2006 9:07 AM
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.
04-17-2006 9:14 AM
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.
04-17-2006 9:14 AM
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.
04-17-2006 9:15 AM
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
04-17-2006 9:23 AM
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.
04-17-2006 9:24 AM
if you know the column position you can use like below.
assign component 2 of structure <sorucefs> to <targetfs>.
Regards
Raja
04-17-2006 1:56 PM