Skip to Content
-3

Is it possible to access a static attribute using me operator in ABAP 7.4

Apr 26, 2017 at 05:47 AM

240

avatar image
Former Member

Hi Folks,

I have an issue in ABAP 7.4 code that i wrote. I have developed an application with a static attribute and by mistake I accessed it using "me" operator and the compiler compiled th

IF ( rv_concession_allowed EQ abap_true ) AND ( me->gv_vic_concession_config EQ abap_false ).
rv_concession_allowed = abap_true.
ELSE.
rv_concession_allowed = abap_false.
ENDIF.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Suhas Saha
Apr 26, 2017 at 07:22 AM
2

Yes, you can. It's not something new to ABAP 740.

Per SAP documentation,

It is also possible to access the static components of a class using the object component selector if an instance of the class was created.

Cf. http://help-legacy.sap.com/abapdocu_740/en/abenclass_component_selector.htm

But IMHO one shouldn't be doing it.

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

okay, actually all these years I knew Class=>static component and me->instance and never experimented as it sits well with what I learnt in OOP. Y'day i did this and while doing a code review I found this and surprised but this is sick and not good where is the sanity then ? :-) Thanks Suhas for replying.

I also find the constant behaves funny did they change it or it too was there?

0

I think the way that an attribute is accessed depends on where it is being accessed from and do not find this behaviour strange at all. Whether an attribute is only accessible via an instantiation (and is public), or whether it is accessible without being instantiated is a matter of 'convenience'. For example, if you want to use constants of a class outside that class you don't really want to instantiate that class each time.

As for accessing a static attribute via 'Me' - well that attribute is part of the class and I would find it weird if that didn't happen

Rich

1
Srinivasa Mukka May 29, 2017 at 09:19 AM
1

@Prasenjit

why dont you check in your abap code instead of writing here...... please read SCN guidelines

Regards,

SM

Share
10 |10000 characters needed characters left characters exceeded
Richard Harper Apr 26, 2017 at 06:57 AM
0

And this is inside an instance of the class ?

Rich

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Yes sir it is inside the instance method of the same class.

0