2008 Jan 28 7:53 PM
Hello everybody!
I'm trying to get dynamically a column value from a field-symbol structure.
Building a a field-symbol and assing values to its columns it is ok.
Reading it dynamically is showing to be the fun stuff.
Let me show you some example-code of what i'm trying to do
(1) starting point:
* building field-symbol structure and value assign
...
ASSIGN COMPONENT 'MY_COLUMN' OF STRUCTURE <DYN_WA_MY_TABLE> TO <L_FIELD>.
<L_FIELD> = 'this is my value'.
...
* end building field-symbol
*Reading field symbol column by name (the good stuff)
data: my_column_name(10) type C, my_column_value(100) type C.
my_column_name = 'MY_COLUMN'. "the name of the column I want to read
my_column_value = <DYN_WA_MY_TABLE>-[my_column_name].
* my_column_value must have 'this is my value'.
Hope this helps. But this was the best way I've found to show you my issue.
Thank you very much for your attention.
Code Formatted by: Alvaro Tejada Galindo on Jan 28, 2008 6:17 PM
2008 Jan 28 10:06 PM
May be this way
report zars no standard page heading
line-size 170
line-count 65(4).
data : begin of itab occurs 0,
my_column1 type c value '1',
my_column2 type c value '2',
my_column3 type c value '3',
my_column4 type c value '4',
my_column5 type c value '5'.
data : end of itab.
data : i_components like rstrucinfo occurs 0 with header line.
field-symbols: <fs> type any.
call function 'GET_COMPONENT_LIST'
exporting
program = 'ZARS'
fieldname = 'ITAB'
tables
components = i_components.
read table i_components with key compname = 'MY_COLUMN1'.
if sy-subrc eq 0.
assign component sy-tabix of structure itab to
<fs>.
write : <fs>.
endif.
read table i_components with key compname = 'MY_COLUMN2'.
if sy-subrc eq 0.
assign component sy-tabix of structure itab to
<fs>.
write : <fs>.
endif.
a®
2008 Jan 28 10:06 PM
May be this way
report zars no standard page heading
line-size 170
line-count 65(4).
data : begin of itab occurs 0,
my_column1 type c value '1',
my_column2 type c value '2',
my_column3 type c value '3',
my_column4 type c value '4',
my_column5 type c value '5'.
data : end of itab.
data : i_components like rstrucinfo occurs 0 with header line.
field-symbols: <fs> type any.
call function 'GET_COMPONENT_LIST'
exporting
program = 'ZARS'
fieldname = 'ITAB'
tables
components = i_components.
read table i_components with key compname = 'MY_COLUMN1'.
if sy-subrc eq 0.
assign component sy-tabix of structure itab to
<fs>.
write : <fs>.
endif.
read table i_components with key compname = 'MY_COLUMN2'.
if sy-subrc eq 0.
assign component sy-tabix of structure itab to
<fs>.
write : <fs>.
endif.
a®
2008 Jan 29 12:22 PM
Hi. The code just works fine.
But now I'm trying to put it on a Function.. I'm getting a sy-subrc = 4 when I read table i_components.
The same code, but changing the exporting program to sy-repid.
call function 'GET_COMPONENT_LIST'
exporting
program = sy-repid
fieldname = 'ITAB'
tables
components = i_components.
2008 Jan 29 1:11 PM
Just knowledge sharing:
It works if the data is declared global to the Group Function.
SOLVED.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |