Skip to Content
author's profile photo Former Member
Former Member

Get a reference of a local class at another program

Hello experts! Sorry if this has been asked before, but I couldn't find exactly what I'm searching for.

Within function-pool MIGO (main program of transaction MIGO), there's a local class LCL_MIGO_KERNEL. This class has the private attribute PT_CHANGE_TAKEIT (which is an internal table).

During the execution of MIGO, for a certain criteria, I would like to clear the contents of PT_CHANGE_TAKEIT. Since it's a private attibute, I have managed to create a new public method that just clears it. This method was defined and inplemented within ENHANCEMENT SPOTS available all over SAPLMIGO. My method is ZZ_CLEAR_PT_CHANGE_TAKEIT. So far so good.

Now, I have to call this method. I have found no other ENHANCEMENT SPOTS in SAPLMIGO at a place where I would me able to make the call (eg, don't know if the criteria fits yet).

Inside BADI MB_MIGO_BADI, method LINE_MODIFY, I have just what I need to know if I should clear PT_CHANGE_TAKEIT.

However, inside here I don't have access to the instance of class LCL_MIGO_KERNEL (the instance itself is (SAPLMIGO)LCL_MIGO_GLOBALS=>KERNEL)

So far I have managed to get a pointer to the instance with:

  FIELD-SYMBOLS: <lfs_kernel> TYPE ANY.

  ASSIGN ('(SAPLMIGO)LCL_MIGO_GLOBALS=>KERNEL')
    TO <lfs_kernel>.

So I have the instance of the class, but how can I call my method ZZ_CLEAR_PT_CHANGE_TAKEIT?

The command call method <lfs_kernel>->zz_clear_pt_change_takeit.

can't be done because ""<LFS_KERNEL>" is not a reference variable" as the sintax check tells me.

I have tried stuff like

  CREATE DATA dref TYPE REF TO
             ('\FUNCTION-POOL=MIGO\CLASS=LCL_MIGO_KERNEL').

  ASSIGN dref->* TO <ref>.

but nothing works so far.

I know if LCL_MIGO_KERNEL was a class from SE24 (not a local one), I could just create a field-symbol of that type instead of type ANY and it would work.

Does anyone have an idea how that can be done?

Thank you very much!

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Aug 27, 2009 at 03:07 PM

    I have managed to do what I needed by calling my method from other ENHANCEMENT SPOTS within SAPLMIGO and some extra coding on MB_MIGO_BADI, but unfortunately I couldn't do what I originaly wanted which was to call a method of a local class from another program, something that could be handy in other situations.

    If it's not lack of knowledge by myself and it really can't be done, I think the ABAP OO framework fell just short of having that flexibility, since I can get the field-symbol to point to the instance of the class, but just can't call the method because of syntax issues.

    Thanks!

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 27, 2009 at 03:07 PM

    My reply was duplicated (I'm sure I clicked Post message only once). It seems that SDN is having some issues with the Security Certificate.

    Edited by: Sérgio Oliveira on Aug 27, 2009 5:07 PM

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.