2008 Apr 07 8:04 AM
Hi!
I' ve a problem with accessing the attributes of objects (global class type) stored in an internal table via READ TABLE ... WITH KEY.
Let' s say my class is something like
CLASS foo DEFINITION.
PUBLIC SECTION.
DATA: foo_key TYPE STRING.
....
and now I' d like to do an operation like
DATA: lt_foo TYPE TABLE OF REF TO foo,
ls_foo like line of lt_foo.
* fill table
...
* read table with special key
READ TABLE lt_foo into ls_foo
WITH KEY foo_key = 'ABC'.
This gives me an compile error.
Has anybody got an idea how to access the objects attributes in the read table-statement?
Regards,
Thomas
2008 Apr 07 10:18 AM
You are appending an instance into an internal table. When you now want to access the attributes you'll have to do this:
loop at lt_foo into ls_foo.
if ls_foo->foo_key = 'ABC'.
DO THIS.
else.
DO THAT / OR DO NOTHING.
endif.
endloop.
Hi!
I' ve a problem with accessing the attributes of objects (global class type) stored in an internal table via READ TABLE ... WITH KEY.
Let' s say my class is something like
CLASS foo DEFINITION.
PUBLIC SECTION.
DATA: foo_key TYPE STRING.
....
and now I' d like to do an operation like
DATA: lt_foo TYPE TABLE OF REF TO foo,
ls_foo like line of lt_foo.
* fill table
...
* read table with special key
READ TABLE lt_foo into ls_foo
WITH KEY foo_key = 'ABC'.
This gives me an compile error.
Has anybody got an idea how to access the objects attributes in the read table-statement?
Regards,
Thomas
2008 Apr 07 10:18 AM
You are appending an instance into an internal table. When you now want to access the attributes you'll have to do this:
loop at lt_foo into ls_foo.
if ls_foo->foo_key = 'ABC'.
DO THIS.
else.
DO THAT / OR DO NOTHING.
endif.
endloop.
2008 Apr 07 10:30 AM
An objects attribute in a table can be accessed via TABLE_LINE->attr.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |