REPORT ZPOPLOG NO STANDARD PAGE HEADING.
******************************************************************
* This abap is run by the system monitoring perl script
* to retrtieve the following data from the different SAP
* systems:
* system status (up/down), appservers, user number per appserver,
* session number per appserver, abap dump number today, 
* today's error message number from the system log,
* number of active lock entries, number of pending updates
******************************************************************
TABLES: SNAP, VBHDR.
DATA: I TYPE I, C(5), J TYPE I, K TYPE I, L TYPE I, SUBRC LIKE SY-SUBRC.
DATA: MINTA(72) VALUE
      'a b c d e f g h i j k l m n o p q r s t u w z x y * | '.
DATA: R(5), HOSTID(8), flag type i.
DATA: BEGIN OF TABTAB OCCURS 10,
       line(128),
END OF TABTAB.
DATA: BEGIN OF SUMMARY OCCURS 50.
        INCLUDE STRUCTURE SAPWLSUMRY.
DATA: END OF SUMMARY.
DATA: BEGIN OF ENQ OCCURS 50.
        INCLUDE STRUCTURE  SEQG3.
DATA: END OF ENQ.
DATA: BEGIN OF TAB OCCURS 10.
        INCLUDE STRUCTURE ABAPLIST.
DATA: END OF TAB.
DATA: BEGIN OF LISTASCI OCCURS 10,
        L(999),
END OF LISTASCI.
DATA: BEGIN OF LIST OCCURS 10.
        INCLUDE STRUCTURE MSXXLIST.
DATA: END OF LIST.
DATA: BEGIN OF USR_TBL OCCURS 10.
        INCLUDE STRUCTURE BTCSYSLOG.
DATA: END OF USR_TBL.
* System name
tabtab-line = 'Q'.
TABTAB-LINE+2 = SY-SYSID.
* The number of abap dumps
SELECT COUNT(*) INTO I FROM SNAP WHERE SEQNO = '001'
AND DATUM = SY-DATUM.
TABTAB-LINE+7(6) = I.
* The number of active lock entries
CALL FUNCTION 'ENQUEUE_READ'
     EXPORTING
          GCLIENT = '*'
          GUNAME  = '*'
          GNAME   = '*'
          GARG    = '*'
     IMPORTING
          SUBRC   = SUBRC
     TABLES
          ENQ     = ENQ.
DESCRIBE TABLE ENQ LINES J.
TABTAB-LINE+14(6)  = J.
* Update records
SELECT COUNT(*) INTO K FROM VBHDR.
TABTAB-LINE+20(6)  = K.
* Today's error messages from the system log
SUBMIT RSLG0001 WITH TR_DAY EQ '0'
LINE-SIZE 255 EXPORTING LIST TO MEMORY AND RETURN.
CALL FUNCTION 'LIST_FROM_MEMORY'
     TABLES
          LISTOBJECT = TAB.
CALL FUNCTION 'LIST_TO_ASCI'
     TABLES
          LISTASCI   = LISTASCI
          LISTOBJECT = TAB.
LOOP AT LISTASCI.
  IF LISTASCI CS '|K|' OR LISTASCI CS '|T|'.
    L = L + 1.
  ENDIF.
ENDLOOP.
TABTAB-LINE+26(6)  = L.
CONDENSE TABTAB.
*APPEND TABTAB.
* Number of active users and modes per app. server
CALL FUNCTION 'TH_SERVER_LIST'
     TABLES
          LIST = LIST.
flag = 0.
LOOP AT LIST.
flag = flag + 1.
* Find out the average response time
  HOSTID = LIST-HOST.
  CALL FUNCTION 'SAPWL_GET_SUMMARY_STATISTIC'
       EXPORTING
            PERIODTYPE = 'D'
            HOSTID     = HOSTID
            STARTDATE  = SY-DATUM
       TABLES
            SUMMARY    = SUMMARY.
  LOOP AT SUMMARY.
    IF SUMMARY-TASKTYPE = 'DIALOG'.
      R = SUMMARY-RESPTI / SUMMARY-COUNT.
      EXIT.
    ENDIF.
  ENDLOOP.
* Count the users and sessions
  CLEAR USR_TBL.
  REFRESH USR_TBL.
  CALL FUNCTION 'SXMI_XMB_USER_LIST_READ_INT' DESTINATION LIST-NAME
   TABLES
          USR_TBL = USR_TBL.
  LOOP AT USR_TBL.
    IF USR_TBL CS 'users logged on with'.
      TRANSLATE USR_TBL USING MINTA.
      CONDENSE USR_TBL.
      if flag > 1.
         tabtab = 'Q @ @ @ @ @ @'.
      endif.
      TABTAB+27 = LIST-NAME.
      TABTAB+48 = USR_TBL.
      TABTAB+68 = R.
      TABTAB+80 = '&'.
      CONDENSE TABTAB.
      APPEND TABTAB.
    ENDIF.
  ENDLOOP.
ENDLOOP.
*
LOOP AT TABTAB.
  WRITE: / TABTAB.
ENDLOOP.