Application Development and Automation 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: 
Read only

Dialog mode in a function module

Former Member
0 Likes
3,110

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

12 REPLIES 12
Read only

Former Member
0 Likes
2,070

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

Read only

0 Likes
2,070

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.

Read only

0 Likes
2,070

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.

Read only

0 Likes
2,070

@Deepak: Yes. Thanks. As mentioned earlier, need to differentiate between manually triggered or triggered in a programmatic manner ?

Read only

0 Likes
2,070

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

Read only

0 Likes
2,070

I stand with my answer:.

In your function:

if sy-tcode eq 'SE37'.

  • -- do your stuff as someone used SE37 and F8

endif.

Read only

0 Likes
2,070

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

Read only

0 Likes
2,070

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"

Read only

0 Likes
2,070

hehe good one!

Was waiting for that to happen.

/gives points to RG.

Read only

0 Likes
2,070

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.

Read only

0 Likes
2,070

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).

Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,070

If you don't want to use SY-TCODE (SE37, SEU_INT or even SE80) use FM SYSTEM_CALLSTACK and look at returned table for event "FUNC" "SFCS_FA_TEST_FUNCTION" or program "SAPLSEUJ".

Regards,

Raymond