Posted: Sat Nov 17, 2007 10:24 pm Post subject: Continuously display the rejected lock requests
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.
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.