04-20-2018 11:26 AM
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
04-21-2018 8:16 AM
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').
04-20-2018 11:36 AM
Sorry , i need explain in details
the classes(local and global) same named and have static meths. and atts.
04-20-2018 11:43 AM
i need to call local class method in some cases , other cases need global classes method.
04-20-2018 12:52 PM
Why on earth would you choose to give your global and local class the same name? Simple solution - change the local class name.
04-20-2018 1:02 PM
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?
04-21-2018 5:10 AM
"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.
04-20-2018 1:00 PM
But what if the local class has same name like global? Same name is possible and local class is prioritized by default.
04-20-2018 1:06 PM
04-20-2018 2:19 PM
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?)
04-20-2018 2:20 PM
Only dynamic with absolute type names ...
https://help.sap.com/http.svc/rc/abapdocu_752_index_htm/7.52/en-US/index.htm?file=abentype_names.htm
04-21-2018 8:16 AM
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').
04-21-2018 9:34 PM
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