SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Как определить, что транзакция запущена?



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP
View previous topic :: View next topic  
Author Message
Мальцев
Участник
Участник



Joined: 28 Sep 2007
Posts: 31

PostPosted: Tue Dec 25, 2007 4:38 pm    Post subject: Как определить, что транзакция запущена? Reply with quote

Добрый день!
Нужно заблокировать повторый запуск z-транзакции.
На ум приходит создать объект блокировки и использовать его в программе. А что произойдет, если программа будет закрыта аварийно, объект блокироки не исчезнет?
Может существуют способы проще?
Спасибо.
Back to top
View user's profile Send private message
John Doe
Модератор
Модератор


Age: 45
Joined: 05 Nov 2007
Posts: 725
Location: КраснАдар

PostPosted: Tue Dec 25, 2007 5:08 pm    Post subject: Reply with quote

Правильно на ум приходит. При дампе блокировка сама снимется (типа ролбэк происходит), а если система упадет - при повторном логоне "выйти из всех приложений" тоже пропадет.

ЗЫ я могу ошибаться, дождемся еще ответов.
Back to top
View user's profile Send private message Blog
july7
Старший специалист
Старший специалист



Joined: 10 Oct 2007
Posts: 109
Location: Киров

PostPosted: Tue Dec 25, 2007 5:15 pm    Post subject: Reply with quote

Я бы тоже сделала объект блокировки. Были случаи, когда сеанс отваливался по тайм-ауту, блокировка не снималась, тогда приходилось идти в SM12.
Back to top
View user's profile Send private message
Lord
Профессионал
Профессионал



Joined: 10 Sep 2007
Posts: 168

PostPosted: Tue Dec 25, 2007 10:02 pm    Post subject: Reply with quote

Попробуйте такой вариант.

Code:

REPORT ZTEST.

DATA: usr_tabl TYPE TABLE OF UINFO WITH HEADER LINE.

PARAMETER p_tcode LIKE usr_tabl-tcode DEFAULT 'SE38'.

CALL FUNCTION 'THUSRINFO'
  TABLES
    usr_tabl = usr_tabl.

WRITE: / p_tcode.
READ TABLE usr_tabl WITH KEY mandt = sy-mandt
tcode = p_tcode.
IF sy-subrc IS INITIAL.
WRITE: 'is running by', usr_tabl-bname.
ELSE.
WRITE: 'is''not running'.
ENDIF.


PS: на скорую руку проверил, была проблема, если от одного пользователя открыты две сессии, например в первой sm38, в другой migo, первая определяется, вторая нет. Нужно посмотреть алгоритм в SM04, попозже разберусь в чем дело.
Back to top
View user's profile Send private message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Sun Jan 13, 2008 11:36 pm    Post subject: Reply with quote

Решение от Rich Heilman
Quote:
I have a requirement to find out whether a program is being executed in background. If the same program is executed manually then it should not execute, the time when the same program is being executed in background.

You can put a lock on the program inside the program, so that when it is run it puts a lock entry in SM12, then anyone trying to run it will get a message saying that the program is locked. USe the TRDIR lock object.


Code:
report zrich_0001 .
data: repid type sy-repid.
repid = sy-repid

call function 'ENQUEUE_E_TRDIR'
  EXPORTING
*     MODE_TRDIR = 'X'
     NAME = repid
*     X_NAME = ' '
*    _SCOPE = '2'
*    _WAIT = ' '
*   _COLLECT = ' '
  EXCEPTIONS
    FOREIGN_LOCK = 1
    SYSTEM_FAILURE = 2
    OTHERS = 3 .
if sy-subrc 0.
  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
     WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.