Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Function Module to open a new session displaying a method of a class

Former Member
0 Kudos

Hello All,

I have a method A of class B.

Now, in my current session, I have a button. When the user clicks on this button, what I expect is that a new session be opened and in the new session method A of class B be displayed.

This is similar to the debugger, wherein, in the debugging mode, we can bring up the context menu in the Source Code (Edit Control) tool, and then select "Go To Source Code".

So basically, I am looking for a Function Module which does the same.

I came across Function Module CC_CALL_TRANSACTION_NEW_TASK, however, this will only create a new session.

I could specify the transaction as SE24, but it then opens a new session with this transaction. That is it.

My objective is to display the method of a class in a new session.

Is there any Function Module in this case?

Regards,

Mithun

Edited by: Mithun Kamath on Aug 9, 2011 5:35 PM

1 ACCEPTED SOLUTION

former_member209703
Active Contributor
0 Kudos

You can try TH_CREATE_MODE, but I still don't understand what you need this for.

7 REPLIES 7

former_member209703
Active Contributor
0 Kudos

You can try TH_CREATE_MODE, but I still don't understand what you need this for.

0 Kudos

Hello Jose,

Thank you for your reply. But the FM does not help.

It is similar to CC_CALL_TRANSACTION_NEW, in fact I think it is the same. It opened SE24 in a new session, but did not execute the screen. Even if it does, then I don't think that it will display the method - there was no input parameter to enter the method.

Regards,

Mithun

0 Kudos

And why don't you try opening the METHOD using SE38??

Since all methods can be accesed by SE38 transaction, maybe you could use those FM passing the Method Name as a parameter.

For instance: ZTEST_CLASS================CM01 (Which is a method of a custom class ZTEST_CLASS)

You can get those includes using this standard FM SEO_CLASS_GET_METHOD_INCLUDES

Regards

0 Kudos

Hello Jose,

Yes! That is a better alternative. But I am not sure if I am doing it right or wrong. Although SE38 is called with that method (=========CM01), the transaction is not executed. If it gets executed, it will display the method.

I want the transaction to be executed as well. The method should already be open, that is the expectation.

I may be asking too much, but I also wanted the source code the go to a specific line, not just open the method.

But the SE38 alternative is indeed a very good one. Rewarding points for that.

Thanks & Regards,

Mithun

0 Kudos

Hi Mithun,

you could use this code to display the ABAP source code:


DATA l_line TYPE i.
DATA l_include TYPE rs38l-include.
l_include = 'CL_GUI_FRONTEND_SERVICES======CM001'.
l_line = 35.
CALL FUNCTION 'EDITOR_PROGRAM'
        EXPORTING
          appid         = 'PG'
          display       = 'X'
          line          = l_line
          program       = l_include
          topline       = l_line
          varied        = 'X'
        EXCEPTIONS
          error_message = 3
          application   = 1
          OTHERS        = 2.

About starting it in a new session (more precisely, it's called an external session), this is technically done using Asynchronous RFC (provided it starts a dialog of course). So you could wrap the code above in a new Z function module that you make RFC-enabled, and you call this FM using CALL FUNCTION ... STARTING NEW TASK ... (asynchronous RFC).

Best regards

Sandra

0 Kudos

Hello Sandra,

Thank you very much. That was exactly what I was looking for.

However, instead of calling EDITOR_PROGRAM directly, what I instea did was the following:

1) Created a RFC enabled Function module.

2) Inside this function module, I wrote the following code:


  SUBMIT tpda_editor_start AND RETURN
   WITH prgm  = is_alert_det-program_name
   WITH incl = is_alert_det-include_name
   WITH dynp = space
   WITH line = is_alert_det-line_no.

The parameters above were similar to the one proposed by you.

Borrowed the above from the class CL_TPDA_SERVICES_TOOLS, method NAVIGATE_TO_SOURCE.

The above is basically called in the debugger, when we use the context menu in the editor tool and invoke the "Goto Source Code" functionality. This eventually calls the EDITOR_PROGRAM FM.

The reason why I did this is because when I was testing the FM, it did not allow me to specify the include as CL_TEST=====CM01. I do not know why, probably I was doing it wrong. But it gave me a message saying that the object does not exist in table TADIR.

Anyway, I did the above steps and it worked exactly as I wanted it to.

I would like to thank you again.

Best Regards,

Mithun

P.S. Forgot to add, I called the above RFC enabled FM as a new task.

Edited by: Mithun Kamath on Aug 10, 2011 4:19 PM

0 Kudos

Hi Mithun,

thank you for the feedback (that's rare in SDN's world) and nice finding! BTW, I always wonder why there are so many ways to do the same thing (I guess SAP development team is so big that it takes time to coordinate development efforts, and also SAP always keep the old 'layers" so finding things is like archeology :-p)

Sandra