2011 Apr 13 2:39 AM
Hi experts
I need to acces in some class wich i enhanced the attribute from other class wich is some levels up in the executing route.
I mean:
CLASS_A calls CLASS_B calls MY_ENHANCED_CLASS->methodX.
CLASS_A is wich has the attribute i need.
So in MY_ENHANCED_CLASS->methodX i need to acces the CLASS_A->attribute (but it's a instance private attribute).
Is there any way to make this acces in code ? or because the attribute is private this is not possible ?
Any help will be usefull.
Thanks & Regards
Frank
2011 Apr 13 5:23 AM
>
> So in MY_ENHANCED_CLASS->methodX i need to acces the CLASS_A->attribute (but it's a instance private attribute).
> Is there any way to make this acces in code ? or because the attribute is private this is not possible ?
I think this is a continuation to your previous question
As you must be knowing cannot access the pvt attribute directly so need some "dirty" workaround.
Something like exporting the value of this attribute to ABAP memory by enhancing the class & accessing the ABAP memory in your method!
BR,
Suhas
PS: I say "dirty" workaround because Private attributes are not meant to be shared outside of the classes. Of course "Friend" classes can access the pvt elements as well
>
> So in MY_ENHANCED_CLASS->methodX i need to acces the CLASS_A->attribute (but it's a instance private attribute).
> Is there any way to make this acces in code ? or because the attribute is private this is not possible ?
I think this is a continuation to your previous question
As you must be knowing cannot access the pvt attribute directly so need some "dirty" workaround.
Something like exporting the value of this attribute to ABAP memory by enhancing the class & accessing the ABAP memory in your method!
BR,
Suhas
PS: I say "dirty" workaround because Private attributes are not meant to be shared outside of the classes. Of course "Friend" classes can access the pvt elements as well
2011 Apr 13 5:23 AM
>
> So in MY_ENHANCED_CLASS->methodX i need to acces the CLASS_A->attribute (but it's a instance private attribute).
> Is there any way to make this acces in code ? or because the attribute is private this is not possible ?
I think this is a continuation to your previous question
As you must be knowing cannot access the pvt attribute directly so need some "dirty" workaround.
Something like exporting the value of this attribute to ABAP memory by enhancing the class & accessing the ABAP memory in your method!
BR,
Suhas
PS: I say "dirty" workaround because Private attributes are not meant to be shared outside of the classes. Of course "Friend" classes can access the pvt elements as well
2011 Apr 13 10:29 AM
Hello,
the other way to work this around is to create a method in Class A, which will return the desired attribute. Then, you just call it in the place, you want to have the attribute value.
You might need to pass the instance of Class A to the method, so it isn't the nicest solution though.
2011 Apr 13 6:16 PM
Thanks Suhas, Piotrzym
With your tips i know now just what i needed.
Best regards
Frank
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |