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: 

Ending a transaction programmatically

Former Member
0 Kudos

I'd like to determine if a particular transaction is running and then terminate it.

The functionality I'm looking for is similar to transaction SM04 where you can terminate a transaction by user.

11 REPLIES 11

ChristianFi
Active Participant
0 Kudos

Search for function starting with TH* (like TH_DELETE_MODE) but I am not sure if I would trust that every transaction exits gracefully - especially concerning update processes.

Christian

0 Kudos

Agreed. We'll certainly check for that.

The exact problem that we have is that we don't want a particular transaction to be active/available when a certain batch job is running.

Making the transaction unavailable for start-up seems pretty straight forward. It's finding the active occurances and terminating them that seems to be more difficult.

As of now, I don't know if terminating the transaction will be graceful or not. But, I'd like to try it.

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

I don't know if you can end the transaction remotely, but maybe you could end the session all together.

Regards,

Rich Heilman

Former Member
0 Kudos

Look at this thread. I have posted a program there. But please be carefule about the pitfalls in that.

Instead, how about locking the transaction before the batch job and unlocking it after, instead of trying to terminate it? Also, you need to consider other ways that would hinder your job. If the transaction is VA01, even if you stop it from executing, how will you monitor all those other ways that will create a sales order like via EDI or via RFCs or through custom programs etc?

Regards,

Srinivas

0 Kudos

Thanks. I've discovered how to prevent new startups of the transaction.

What I need to do is end any active sessions before the batch job starts.

0 Kudos

Instead of ending, may be you should just wait until the transaction is completed and then start the job.

Let us say you have a program that monitors if the transaction is running. If it is running, then it just goes into a loop until the transaction has ended. Since you are stopping any new ones becoming active, you only will wait until the active ones are done. Once done, the execution of this program ends. Your batch job, should have this program as a predecessor step.

Srinivas

Former Member
0 Kudos

Hi

You cannot catch a tcode but with Function TH_WPINFO you can catch if a program related to tcode is running.

You can cancel the program . See the code in subroutine

PROG_EXIT in program RSMON000_ALV .

Otherwise you can use tcode SM50.

Cheers

guillaume-hrc
Active Contributor
0 Kudos

Yes, the SM04 transaction seems to use the 'TH_DELETE_USER' function.

Or maybe you could try to directly call the routine <b>DELETE_USER</b> in the RSM04000_ALV ?

Former Member
0 Kudos

Hi

Active programs can be cancelled from SM50 Program/Mode -> Program -> Cancel. you can leverage the code here .

If answers were helpful reward and close the thread.

Cheers

0 Kudos

You could use EXIT_SAPLSABE_010 to avoid that a user can start a report (of type 1). In this exit you could check if your batch program is running.

I am sure there is something similar for modul pools as well.

Christian

0 Kudos

If these answers helped you, please reward and close the post.

Thanks,

Srinivas