Skip to Content
avatar image
Former Member

abap same name local and global class

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

Add comment
10|10000 characters needed characters exceeded

  • 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?)

  • Former Member

    Sorry , i need explain in details

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

  • Former Member

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

  • Get RSS Feed

4 Answers

  • Best Answer
    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').
    
    Add comment
    10|10000 characters needed characters exceeded

  • Apr 20 at 11:52 AM

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

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 20 at 01:20 PM
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 21 at 08: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

    Add comment
    10|10000 characters needed characters exceeded