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

Continuously display the rejected lock requests



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> SQL and Database Changes
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Sat Nov 17, 2007 10:24 pm    Post subject: Continuously display the rejected lock requests Reply with quote

Code:
 
REPORT ZENQLIST NO STANDARD PAGE HEADING.
***********************************************************************
* Continuously display the rejected lock requests
* Useful tool to detect bottlenecks on particular tables
***********************************************************************
DATA: ENQ_LOCATION(70), LASTLINE TYPE I, FIRSTLINE TYPE I, FLAG TYPE I,
OLDLINE(200).
DATA: BEGIN OF LINE_TBL OCCURS 0.
        INCLUDE STRUCTURE SPFLIST.
DATA: END OF LINE_TBL.
DATA: BEGIN OF RES_TBL OCCURS 0.
        INCLUDE STRUCTURE SPFLIST.
DATA: END OF RES_TBL.
DATA: BEGIN OF ITAB OCCURS 5.
        INCLUDE STRUCTURE THLINES.
DATA: END OF ITAB.
*
START-OF-SELECTION.
* Status for safe exit:
  SET PF-STATUS 'SAFESTOP'.
* Figure out the location of the ENQLOG
* Start the enq logging
  CALL 'C_ENQUEUE' ID 'OPCODE' FIELD 'X'.
  CALL FUNCTION 'Z_ENQUEUE_DELAY'
         STARTING NEW TASK 'WAIT'
         PERFORMING WHEN_FINISHED ON END OF TASK.
  WRITE: ''.
*
AT USER-COMMAND.
  IF SY-UCOMM = 'SAFE'.
* Stop the enque logging and exit
    CALL 'C_ENQUEUE' ID 'OPCODE' FIELD 'Y'.
    SET SCREEN 0.
    LEAVE SCREEN.
  ENDIF.
  SY-LSIND = SY-LSIND - 1.
  CALL FUNCTION 'TH_REQUEST_QUEUE'
       TABLES
            REQUEST_QUEUES = ITAB.
* Read and display the enqlog file
  CALL FUNCTION 'ENQUEUE_READ_LOG'
       TABLES
            LOGLINES = LINE_TBL
       EXCEPTIONS
            OTHERS   = 1.
* Display the last 25 entries
  FLAG = 0.
  CLEAR RES_TBL. REFRESH RES_TBL.
  LOOP AT LINE_TBL.
    IF LINE_TBL CS 'SLEEP'.
      FLAG = 1.
    ELSE.
      IF FLAG = 0 AND LINE_TBL CS 'Rejected'.
        RES_TBL = OLDLINE.
        APPEND RES_TBL.
      ELSE.
        OLDLINE = LINE_TBL.
        DELETE LINE_TBL.FLAG = 0.
      ENDIF.
    ENDIF.
  ENDLOOP.
*
  WRITE: / 'List of the last 25 rejected lock requests'.
  WRITE: / SY-DATUM, SY-UZEIT.
  SKIP.
  DESCRIBE TABLE RES_TBL LINES LASTLINE.
  FIRSTLINE = LASTLINE - 25.
  IF FIRSTLINE <= 1. FIRSTLINE = 1. ENDIF.
  IF LASTLINE > FIRSTLINE.
    LOOP AT RES_TBL FROM FIRSTLINE TO LASTLINE.
      WRITE: / RES_TBL-LINE.
    ENDLOOP.
  ENDIF.
*
  CALL FUNCTION 'Z_ENQUEUE_DELAY'
       STARTING NEW TASK 'INFO'
       PERFORMING WHEN_FINISHED ON END OF TASK.
*
FORM WHEN_FINISHED USING TASKNAME.
  RECEIVE RESULTS FROM FUNCTION 'Z_ENQUEUE_DELAY'.
  SET USER-COMMAND 'BUMM'.
ENDFORM.
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 -> SQL and Database Changes 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.