2007 Jun 11 8:01 AM
Hi all,
i'm a newbie in programming OO. So i have a little Problem with my Coding.
i have to change a value vom a structure. It an public instance attribute from the superclass. So how can i change it?
coding it like this:
go_busobj_created-ms_detail-nr = '1020'.shows an error that go_busobj_created ist an objectreferenz and does'n own a component "ms_detail-snunr" - But in debugging i can navigate with doubleclick into ms_detail and ich can change manually thy value.
The other way i tried is using the method from a superclass that my object (go_busobj_created) inherits during runtime. But i don't know how to call it.
call METHOD CL_SUPERCLASS=>('SET_NR')
or
call METHOD ('IF_SUPERCLASS~SET_NR')I can call static or dynamic - everytime it dumps..
Thanks for your help.
Stefan
2007 Jun 11 8:24 AM
Hello Stefan
Based on my knowledge from RE-FX I assume that GO_BUSOBJ is a very generic object reference. Thus, in order to access the instance attribute MS_DETAIL you have to do a narrowing cast:
DATA:
go_busobj TYPE REF TO <generic class>,
go_specific TYPE REF TO <specific class which is a subclass of generic class>.
go_specific ?= go_busobj. " narrowing cast
go_specific_created->ms_detail-nr = '1020'.For example, the BDT function modules in RE-FX pass most (if not all) object references as TYPE REF TO cl_reca_storable. The actual object may be a contract (CL_RECN_CONTRACT), a building (CL_REBD_BUILDING) or some other RE object.
Regards
Uwe
Hi Stefan,
If it's an instance attribute, first you have to create an object reference to your class. Then you can modify the attribute of that instance.
data: gro_something type ref to cl_myclass.
...
create object gro_something.
...
gro_something-ms_detail-nr = '1020'.
Best regards,
Peter
2007 Jun 11 8:06 AM
Hi Stefan,
If it's an instance attribute, first you have to create an object reference to your class. Then you can modify the attribute of that instance.
data: gro_something type ref to cl_myclass.
...
create object gro_something.
...
gro_something-ms_detail-nr = '1020'.
Best regards,
Peter
2007 Jun 11 8:12 AM
Hi,
i defined it like this:
DATA go_busobj_created TYPE REF TO IF_BUS_OBJECT.
in this IF the Object doesn't know the methods or the attribute.
it's known only during program runtime.
the go_busobj_created is created by another method i called (create obj by template)
is it relevant?
Message was edited by:
Stefan Mett
Message was edited by:
Stefan Mett
2007 Jun 11 8:24 AM
Hello Stefan
Based on my knowledge from RE-FX I assume that GO_BUSOBJ is a very generic object reference. Thus, in order to access the instance attribute MS_DETAIL you have to do a narrowing cast:
DATA:
go_busobj TYPE REF TO <generic class>,
go_specific TYPE REF TO <specific class which is a subclass of generic class>.
go_specific ?= go_busobj. " narrowing cast
go_specific_created->ms_detail-nr = '1020'.For example, the BDT function modules in RE-FX pass most (if not all) object references as TYPE REF TO cl_reca_storable. The actual object may be a contract (CL_RECN_CONTRACT), a building (CL_REBD_BUILDING) or some other RE object.
Regards
Uwe
2007 Jun 11 8:37 AM
| User | Count |
|---|---|
| 6 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |