怎样使程序只运行一个实例

来源:互联网 发布:大数据金融有哪些风险 编辑:程序博客网 时间:2024/05/16 17:41

SAP提供了两个FM来解决程序运行时的同步锁定问题。 ENQUEUE_ES_PROG和DEQUEUE_ES_PROG。

ENQUEUE_ES_PROG
Summary
Prevents the parallel execution of a program.
Description
This function creates a lock in a program that should not be processed more than once, simultaneously.
The lock remains in place until either the DEQUEUE_ES_PROG function module
is called or the transaction is completed (with an implicit DEQUEUE_ALL call).
Parameters
EXPORTING
NAME Program name to lock
SCOPE Controls how the lock is passed to the update program:
Value Meaning
1 The lock is not passed to the update program. The lock
is removed when the transaction ends.
2 (default) The lock is passed to the update program. The update
program is responsible for removing the lock.
3 The lock is passed to the update program. The lock must
be removed in both the interactive program and in the
update program.

 

DEQUEUE_ES_PROG
Summary
Releases program locks.
Description
This function releases a lock in a program that has been set by ENQUEUE_ES_PROG.
Parameters
EXPORTING
NAME Program name to lock

使用时需要注意下列问题:

1 程序在锁定后,解锁的动作不是必须的,程序退出或者完成后会自动解锁。

2 程序的锁定只对前台程序有用,如果运行的是后台服务,则需要其他的解决方案。可以考虑使用如下方法:a 将AS配置为同一程序只允许同时运行一个JOB。 b 通过判断表TBTCO的JOB状态字段来解决。

3锁定的FM在不同的事件中运行效果不同,请根据具体的需求来确定该在何种事件后锁定。

原创粉丝点击