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: 

How to deterine the running mode?

Former Member
0 Kudos

Within the enhancement SAPMF02D (has a function exit), I need to know which mode the current program is running in, such as in Display mode (Display Customer) or in Change mode (Change Customer).

What's the best way to do it?

Thank you very much!!!

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Thank you so much for your replies!

I've tried this way before. But the problem is that, say, first I run tcode xd03 to display the customer, then I can click on the Change Icon to switch to the Change Mode. However, the tcode is still xd03, instead of xd02.

So I thought maybe there are other ways to do it.

Thank you!

10 REPLIES 10

Former Member
0 Kudos

Hi yun,

1. The FM in this exit does not provide

anything for detecting the mode.

2. However,

we can use sy-tcode

to know, which is the current transaction code.

(This same technique is used in almost

all sap transactions, to detect the mode

- display, change, create,delete etc,

bcos the program is same for all these activities,

so, the distinguishing factor is only the tcode)

3. In your case also,

FD02= change customer

FD03 = display customer

FD01 = create customer

(u can check all these tcodes in se80,

program SAPMF02D)

4.<b> Not only this is the best way,

THIS IS THE ONLY WAY.</b>

(in the most direct & practical approach)

regards,

amit m.

naimesh_patel
Active Contributor
0 Kudos

Hello,

Check on the T-code is the most suitable way for your requirement.

Regards,

Naimesh

Former Member
0 Kudos

Thank you so much for your replies!

I've tried this way before. But the problem is that, say, first I run tcode xd03 to display the customer, then I can click on the Change Icon to switch to the Change Mode. However, the tcode is still xd03, instead of xd02.

So I thought maybe there are other ways to do it.

Thank you!

0 Kudos

Hi yun,

1. Just check out

the value of sy-ucomm in the user exit.

2. It must be UPDA (for edit)

regards,

amit m.

0 Kudos

Hello Yun,

This user exit should be called whenever user presses save button. The description of the FM is like "Customers: User Exit for Checks prior to Saving". SO, this will be called in only create and change mode. Not in the Dispaly mode.

Try to set the break point and do the debug, you will have better idea.

Regards,

Naimesh

0 Kudos

Thank you very much!

Should read the description carefully.

Former Member
0 Kudos

Hi,

You can check with the screen attributes in the userexit.

Screen attributes of the field, checking such as : input, output etc.

This will have the correct information of the screen during runtime.

Please award some points, if found useful.

Thanks,

Bharadwaj

0 Kudos

Hi, B raju

Your information is helpful too! But that screen merely contains two subscreen areas. So I couldn't get the attribute of the screen fields.

0 Kudos

Hi Yun,

This code will help you in identifying if customer is currently opened in edit or change mode. Hope you can use this logic in building your code.

REPORT ZSA_3 .

tables: SEQG3, kna1.

data i_enq like SEQG3 occurs 0 with header line.

CALL FUNCTION 'ENQUEUE_READ'

EXPORTING

GCLIENT = SY-MANDT

GNAME = 'KNA1'

  • GARG = ' '

GUNAME = SY-UNAME

  • LOCAL = ' '

  • IMPORTING

  • NUMBER =

  • SUBRC =

TABLES

ENQ = i_enq

EXCEPTIONS

COMMUNICATION_FAILURE = 1

SYSTEM_FAILURE = 2

OTHERS = 3

.

if not i_enq-GARG is initial.

write: 'Customer',i_enq-GARG+3(10), 'is currently opened in edit mode'.

else.

Write 'No customer is currently opened in display mode'.

endif.

plz award some points if find it useful.

Thanks & Regards,

Sandeep Arora

0 Kudos

Thanks for your reply!

I also found that I could use T020 to determine the running mode.

Thanks!