‎2011 Sep 26 11:19 AM
Hi,
Is there a way to identify whether a function module is called in a dialog mode or if the function module is called by any other program? Is there a SY variable or any other method, which can give us a hint that the function module is executed by pressing F8 or not. I want to handle the use case accordingly, based on the mode of invocation of the function module. Could you please help me ?
-- Santhosh
‎2011 Sep 26 11:57 AM
Dialog mode = SE37? If so, just check the sy-tcode.
But isn't that something you're supposed to know (i saw your business card)?
‎2011 Sep 26 12:05 PM
Hi ,
i think santosh is looking Answer for ; How to catch whether function module which is executed by Pressing F8 or By driving program execution or By any Dialog Programing Module pool .
i Hope i am correct .
regards
Deepak.
‎2011 Sep 26 12:16 PM
Thanks. But I'm looking for a way to know inside the function module, whether it was triggered in an interactive mode (that is by SE37 and F8) or it is called by any other report or a function module.
Basically I want to prevent the manual execution of the function module in certain systems. But it is okay, if that function module is called by another program, let us say, a report.
‎2011 Sep 26 12:19 PM
@Deepak: Yes. Thanks. As mentioned earlier, need to differentiate between manually triggered or triggered in a programmatic manner ?
‎2011 Sep 26 12:21 PM
Hi.
When the FM is running(or assume that some Dialog FM is running), Goto SM50 & observe the entry for the DIALOG type work processors. If the FM is under any one of the DIA(Dialog) WP type, it is to understand that the FM is a dialog called one....
Also, use SM04 for the User credentials of the FM...
~ Guru
‎2011 Sep 26 12:28 PM
I stand with my answer:.
In your function:
if sy-tcode eq 'SE37'.
-- do your stuff as someone used SE37 and F8
endif.
‎2011 Sep 26 12:43 PM
Hi Santosh ,
When Function module is bein Executed by Pressing F8 then there will be always sy-tcode = SE37 ,
when in Dialog program (module pool is there for execution sy-tcode will be Transaction code given for that Dialogprogram . When Program is executed there will be se38 in sy-tocde or transaction code given if executed through Transaction code .
if you are Creating Z function module then you can check for sy-tcode as said by Maen or
have lock on function module and check what to do after that by checking sy-tcdoe .
Regards
deepak.
Edited by: Deepak Dhamat on Sep 27, 2011 9:23 AM
‎2011 Sep 27 1:09 PM
there will be always sy-tcode = SE37
Are you sure ? Create a simple test FM like
FUNCTION z_rgs.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" EXPORTING
*" REFERENCE(TCODE) TYPE SY-TCODE
*"----------------------------------------------------------------------
tcode = sy-tcode.
ENDFUNCTION.Now test this FM via SE37 and then via SE80...
Regards,
Raymond
(*) first time it returns "SE37" and second time it returns "SEU_INIT"
‎2011 Sep 27 1:13 PM
hehe good one!
Was waiting for that to happen.
/gives points to RG.
‎2011 Sep 27 3:28 PM
I called the above function module in a report and the value of TCODE was SE38. So I'm still hestiant to use this logic to check the interactive mode.
‎2011 Sep 28 9:42 AM
I called the above function module in a report and the value of TCODE was SE38. So I'm still hestiant to use this logic to check the interactive mode.
I guess that if you call the function from a method in the class builder, the tcode will be SE24. But these are all development related transactions and those are the ones you need to check. Normal users will not be using those transactions (at least i hope they won't).
‎2011 Sep 26 12:36 PM