Skip to Content
0

abap same name local and global class

Apr 20 at 10:26 AM

134

avatar image
Former Member

Hello;

in abap program ,

i have local class same named with global class.

Which way i can call global classes methods or attributes ?

Any code snippet ?

Thanks

10 |10000 characters needed characters left characters exceeded
Former Member

Sorry , i need explain in details

the classes(local and global) same named and have static meths. and atts.

0
Former Member

i need to call local class method in some cases , other cases need global classes method.

0

Did you try to use some absolute name to identify the classes, trying some id such as '\PROGRAM=ZTEST\CLASS=CL_TEST' vs '\CLASS=CL_TEST' to use in some dynamic method call as (class_name)=>(meth_name) I'm not optimistic about this. (Also I never used same name for two classes, never required it, why did you do that?)

1
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Best Answer
Cesar A. Apr 21 at 07:16 AM
-1

It is what Horst says. Check this out.

*DATA LO_YOUROBJECT TYPE REF TO OBJECT.
*CREATE OBJECT LO_YOUROBJECT TYPE ('\CLASS=ZCL_YOURCLASS')
*  EXPORTING
*    IV_TABLE_NAME = 'ZSD_YOURTABLE'
*  .
*
*call method LO_YOUROBJECT->('YOUR_METHOD').
Share
10 |10000 characters needed characters left characters exceeded
Matthew Billingham
Apr 20 at 11:52 AM
3

Why on earth would you choose to give your global and local class the same name? Simple solution - change the local class name.

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

It is right to recommend renaming and I also do not know reason to name both classes same name.

But it is still valid question. Is it possible to call global class and how?

1

"Why on earth would you choose to give your global and local class the same name?"

You're asking something/someone who doesn't give their name and repeats a fake one.

3
Horst Keller
Apr 20 at 01:20 PM
0
Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Apr 21 at 08:34 PM
0

thanks to everyone;

acccesing global class meth: call method ('\class=zcl_samename')=global_meth

accesing local class meth: zcl_samename=>local_meth

why i don't give a different name to local class:

local class's definitons and implements are in different includes . And these includes are being used by to much progs , funcs vs.

Global class is in a purchased packet.

I also need two classes of methods in my program

Regards

Share
10 |10000 characters needed characters left characters exceeded