본문 바로가기

SAP BC-프로그램

일일 간편 시스템 모니터링 프로그램

모듈 : BC
기능 설명 : 일일 모니터링 항목에 간편 확인
사용 예시 : RFC 연결을 통해 여러 ERP 시스템의 OS/DB/ABAP 단 일일 모니터링 항목 간편 확인
버전 : 소스코드 Modification Log 참조

❗❗ 유의사항
1. 지원 DB 는 현재 Oracle, HANA 입니다.
2. 비교적 예전 SAP NW, SAP_BASIS 버전에서는 RFC Function 의 HANA 부분 오브젝트로 인해 오류가 발생할 수 있습니다. 해당 오류 부분 소스코드를 주석처리 하시면 됩니다.
3. 모니터링 항목 중, Filesystem, SM21 Syslog 부분은 아직 미구현 상태입니다.


1. 소스 코드

***********************************************************************
* Report            : ZBC_SYSTEM_MONITORING                           *
* Module/Sub-Module : BC                                              *
* Description       : Easy Daily Monitoring of SAP System             *
***********************************************************************
*                          MODIFICATION LOG                           *
*                                                                     *
* DATE       AUTHORS            DESCRIPTION                           *
* ---------- ------------------ ------------------------------------- *
*             YHJ               Initial Release                       *
* 2024.02.23  YHJ               RFC Connection Exception add          *
***********************************************************************
*                                                                     *
* - 모니터링 항목                                                     *
*  1. AP 서비스 확인                                                  *
*  2. OS CPU, Memory, //FileSystem// 확인                              *
*  3. DB 백업 확인                                                    *
*  4. DB 사용량/여유량 확인                                           *
*   ㄴ Oracle : TableSpace PSAPSR3/ PSAPSR3USR TOTAL, USED, FREE      *
*   ㄴ HANA   : DISK/ Memory TOTAL, USED, FREE                        *
*  5. DBA 작업 확인                                                   *
*  6. DB LOCK 확인                                                    *
*  7. DB Alert 확인                                                   *
*  8. 배치잡 수행 확인                                                *
*  9. ABAP 덤프 확인                                                  *
*  //10. 시스템 로그 확인                                             *
*  11. ABAP LCOK 확인                                                 *
*  12. 작업 프로세스 확인                                             *
*  13. 업데이트 시스템 및 요청 확인                                   *
*  14. 스풀 사용량 확인                                               *
*  15. 사용자 세션 확인                                               *
*  16. SAP Memory, Buffer 확인                                        *
*  17. RFC Queue 확인                                                 *
***********************************************************************

REPORT ZBC_SYSTEM_MONITORING.

*----------------------------------------------------------------------*
* TYPE-POOLS
*----------------------------------------------------------------------*
TYPE-POOLS: SLIS, ICON.


*----------------------------------------------------------------------*
* TABLES
*----------------------------------------------------------------------*
TABLES: SSCRFIELDS.


*----------------------------------------------------------------------*
* DATA
*----------------------------------------------------------------------*

DATA: GT_MONI_DATA    LIKE TABLE OF ZBC_MONI_DATA          WITH HEADER LINE.

DATA: GT_PROFILE      LIKE TABLE OF ZBC_MONI_PROFILE       WITH HEADER LINE,
      GT_PROFILE_DEF  LIKE TABLE OF ZBC_MONI_PROFILE       WITH HEADER LINE.

DATA: GT_COLL_DATA     LIKE TABLE OF ZBC_MONI_COLLECT_DATA  WITH HEADER LINE.

DATA: BEGIN OF GT_DATA OCCURS 0,
        SEL(1)                TYPE C,
        AP_COUNT_S(4)         TYPE C,
        AP_STATE_S(4)         TYPE C,
        OS_CPU_USED_S(4)      TYPE C,
        OS_CPU_5AVG_S(4)      TYPE C,
        OS_MEM_USED_S(4)      TYPE C,
        OS_MEM_SWAP_S(4)      TYPE C,
        DB_BACKUP_S(4)        TYPE C,
        DB_ORA_SR3_USED_S(4)  TYPE C,
        DB_ORA_USR_USED_S(4)  TYPE C,
        DB_HDB_MEM_USED_S(4)  TYPE C,
        DB_HDB_DIS_USED_S(4)  TYPE C,
        DB_DBA_ERROR_S(4)     TYPE C,
        DB_LOCK_ERROR_S(4)    TYPE C,
        DB_ALERT_COUNT_S(4)   TYPE C,
        ABAP_BTC_AERR_S(4)    TYPE C,
        ABAP_BTC_SERR_S(4)    TYPE C,
        ABAP_BTC_ZERR_S(4)    TYPE C,
        ABAP_DUMP_COUNT_S(4)  TYPE C,
        ABAP_ENQ_LOCK_S(4)    TYPE C,
        ABAP_WP_DIA_S(4)      TYPE C,
        ABAP_WP_BGD_S(4)      TYPE C,
        ABAP_UPD_STATE_S(4)   TYPE C,
        ABAP_UPD_ERR_S(4)     TYPE C,
        ABAP_SPOOL_PER_S(4)   TYPE C,
        ABAP_DEAD_SESS_S(4)   TYPE C,
        ABAP_BUF_SWAP_S(4)    TYPE C,
        ABAP_MEM_ROLL_S(4)    TYPE C,
        ABAP_MEM_PAGE_S(4)    TYPE C,
        ABAP_MEM_EXTM_S(4)    TYPE C,
        ABAP_MEM_EXTG_S(4)    TYPE C,
        ABAP_MEM_SHRO_S(4)    TYPE C,
        ABAP_MEM_HEAP_S(4)    TYPE C,
        ABAP_TRFC_ERR_S(4)    TYPE C,
        ABAP_QRFC_OERR_S(4)   TYPE C,
        ABAP_QRFC_IERR_S(4)   TYPE C.
        INCLUDE STRUCTURE ZBC_MONI_DATA.
DATA: END OF GT_DATA.

DATA: BEGIN OF GT_REPORT OCCURS 0,
        SEL(1)         TYPE C,
        LINECOLOR(4)   TYPE C,
        R_OBJECT(20)   TYPE C,
        R_VALUE(20)    TYPE C,
        R_PROFILE1(5)  TYPE C,
        R_PROFILE2(5)  TYPE C,
        R_EVAL(4)      TYPE C.
DATA: END OF GT_REPORT.

DATA: FUNCTXT      TYPE SMP_DYNTXT.


*### RFC Destination 데이터
DATA: BEGIN OF GV_SID OCCURS 0,
        ZSID(3)  TYPE C,
        RFCSID   TYPE STRING,
        TXTSID   TYPE STRING.
DATA: END OF GV_SID.


*----------------------------------------------------------------------*
* SELECTION-SCREEN
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE t001.

  SELECTION-SCREEN SKIP 1.

  SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE t002.

    SELECTION-SCREEN SKIP 1.

    PARAMETERS: P_SID LIKE SY-SYSID.

    SELECT-OPTIONS: S_DATE  FOR SY-DATUM NO-EXTENSION DEFAULT SY-DATUM.

    SELECTION-SCREEN SKIP 1.

  SELECTION-SCREEN END OF BLOCK b2.

SELECTION-SCREEN END OF BLOCK b1.


SELECTION-SCREEN: FUNCTION KEY 1, FUNCTION KEY 2.

AT SELECTION-SCREEN.
  PERFORM MENU_SELECT.

AT SELECTION-SCREEN OUTPUT.
  PERFORM MODIFY_SCREEN.

*----------------------------------------------------------------------*
* INITIALIZATION                                                       *
*----------------------------------------------------------------------*
INITIALIZATION.
  PERFORM MENU_BAR.
  PERFORM SET_SID.
*  PERFORM SET_DEAFULT_PROFILE.

  MOVE 'Easy Daily Monitoring of SAP System' TO t001.
  MOVE 'Report View' TO t002.


*----------------------------------------------------------------------*
* START-OF-SELECTION.
*----------------------------------------------------------------------*
START-OF-SELECTION.

  "### 백그라운드 수행
  IF SY-BATCH = 'X'.

    "###  1. 모니터링 데이터 RFC 수집
    PERFORM MONI_COLLECT_DATA_RFC.

  "### 프론트 수행
  ELSE.

    "### 1. 모니터링 데이터 셀렉트
    PERFORM SELECT_MONI_DATA.

    "### 2. 수집 데이터를 바탕으로, 모니터링 평가지표 생성
    PERFORM EVALUTAION_MONI_DATA.

    "### 3. 모니터링 평가지표 출력
    PERFORM RESULT_VIEW TABLES GT_DATA.

  ENDIF.


*----------------------------------------------------------------------*
* END-OF-SELECTION.
*----------------------------------------------------------------------*
END-OF-SELECTION.



*&---------------------------------------------------------------------*
*& ZBC_SYSTEM_MONITORING_F01
*&---------------------------------------------------------------------*

*&---------------------------------------------------------------------*
*&      Form  MENU_SELECT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM MENU_SELECT .

  "### DATA - FC01
*  DATA: LT_FIELDCAT     TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.
*  DATA: LT_EXCL         TYPE SLIS_T_EXTAB WITH HEADER LINE.

  CASE SY-UCOMM.

    "### 메뉴_01 : 프론트 모니터링 데이터 수집
    WHEN 'FC01'.

      PERFORM MONI_COLLECT_DATA_RFC.

    "### 메뉴_02 : Profile 설정 확인
    WHEN 'FC02'.

      PERFORM PROFILE_VIEW.

  ENDCASE.

ENDFORM.

*&---------------------------------------------------------------------*
*&      Form  MODIFY_SCREEN
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM MODIFY_SCREEN .

  %_P_SID_%_APP_%-TEXT   = 'SID'.
  %_S_DATE_%_APP_%-TEXT  = 'Date'.

ENDFORM.

*&---------------------------------------------------------------------*
*&      Form  MENU_BAR
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM MENU_BAR .

  FUNCTXT-ICON_ID = ICON_WRITE_FILE.
  FUNCTXT-QUICKINFO = 'Collect Data'.
  FUNCTXT-ICON_TEXT = 'Collect Data'.
  SSCRFIELDS-FUNCTXT_01 = FUNCTXT.

  FUNCTXT-ICON_ID = ICON_VIEW_TABLE.
  FUNCTXT-QUICKINFO = 'Profile'.
  FUNCTXT-ICON_TEXT = 'Profile'.
  SSCRFIELDS-FUNCTXT_02 = FUNCTXT.

ENDFORM.

*&---------------------------------------------------------------------*
*&      Form  SET_SID
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM SET_SID .

  REFRESH: GV_SID.

  GV_SID-ZSID = 'SA1'. GV_SID-RFCSID = 'SA1CLNT000'. GV_SID-TXTSID = 'SA1'. APPEND GV_SID.
  GV_SID-ZSID = 'SA2'. GV_SID-RFCSID = 'SA2CLNT000'. GV_SID-TXTSID = 'SA2'. APPEND GV_SID.
  GV_SID-ZSID = 'SA3'. GV_SID-RFCSID = 'SA3CLNT000'. GV_SID-TXTSID = 'SA3'. APPEND GV_SID.

  GV_SID-ZSID = 'SB1'. GV_SID-RFCSID = 'SB1CLNT000'. GV_SID-TXTSID = 'SB1'. APPEND GV_SID.
  GV_SID-ZSID = 'SB2'. GV_SID-RFCSID = 'SB2CLNT000'. GV_SID-TXTSID = 'SB2'. APPEND GV_SID.
  GV_SID-ZSID = 'SB3'. GV_SID-RFCSID = 'SB3CLNT000'. GV_SID-TXTSID = 'SB3'. APPEND GV_SID.

  GV_SID-ZSID = 'SC1'. GV_SID-RFCSID = 'SC1CLNT000'. GV_SID-TXTSID = 'SC1'. APPEND GV_SID.
  GV_SID-ZSID = 'SC2'. GV_SID-RFCSID = 'SC2CLNT000'. GV_SID-TXTSID = 'SC2'. APPEND GV_SID.
  GV_SID-ZSID = 'SC3'. GV_SID-RFCSID = 'SC3CLNT000'. GV_SID-TXTSID = 'SC3'. APPEND GV_SID.


ENDFORM. 

*&---------------------------------------------------------------------*
*&      Form  SET_DEAFULT_TEMPLATE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM SET_DEAFULT_PROFILE USING P_SET_SID.

  DATA: LT_PROFILE_FIELD LIKE TABLE OF DD03L WITH HEADER LINE.

  CLEAR: GT_PROFILE_DEF. REFRESH: GT_PROFILE_DEF.

  SELECT FIELDNAME POSITION INTO CORRESPONDING FIELDS OF TABLE LT_PROFILE_FIELD
    FROM DD03L
    WHERE TABNAME = 'ZBC_MONI_COLLECT_DATA'.

  SORT LT_PROFILE_FIELD BY POSITION.

  LOOP AT LT_PROFILE_FIELD.

    GT_PROFILE_DEF-SID       = P_SET_SID.
    GT_PROFILE_DEF-TYPE      = '2'.
    GT_PROFILE_DEF-OBJECT    = LT_PROFILE_FIELD-FIELDNAME.

    CASE LT_PROFILE_FIELD-FIELDNAME.
      WHEN 'AP_COUNT'.        GT_PROFILE_DEF-THRESHOLD = 0.
      WHEN 'AP_STATE'.        GT_PROFILE_DEF-THRESHOLD = 1.

      WHEN 'OS_CPU_USED'.     GT_PROFILE_DEF-THRESHOLD = 90.
      WHEN 'OS_CPU_5AVG'.     GT_PROFILE_DEF-THRESHOLD = 5.
      WHEN 'OS_MEM_USED'.     GT_PROFILE_DEF-THRESHOLD = 90.
      WHEN 'OS_MEM_SWAP'.     GT_PROFILE_DEF-THRESHOLD = 50.

      WHEN 'DB_BACKUP'.       GT_PROFILE_DEF-THRESHOLD = 1.
      WHEN 'DB_ORA_SR3_USED'. GT_PROFILE_DEF-THRESHOLD = 95.
      WHEN 'DB_ORA_USR_USED'. GT_PROFILE_DEF-THRESHOLD = 95.
      WHEN 'DB_HDB_MEM_USED'. GT_PROFILE_DEF-THRESHOLD = 90.
      WHEN 'DB_HDB_DIS_USED'. GT_PROFILE_DEF-THRESHOLD = 90.
      WHEN 'DB_DBA_ERROR'.    GT_PROFILE_DEF-THRESHOLD = 1.
      WHEN 'DB_LOCK_ERROR'.   GT_PROFILE_DEF-THRESHOLD = 1.
      WHEN 'DB_ALERT_COUNT'.  GT_PROFILE_DEF-THRESHOLD = 5.

      WHEN 'ABAP_BTC_AERR'.   GT_PROFILE_DEF-THRESHOLD = 5.
      WHEN 'ABAP_BTC_SERR'.   GT_PROFILE_DEF-THRESHOLD = 1.
      WHEN 'ABAP_BTC_ZERR'.   GT_PROFILE_DEF-THRESHOLD = 5.
      WHEN 'ABAP_DUMP_COUNT'. GT_PROFILE_DEF-THRESHOLD = 50.
      WHEN 'ABAP_ENQ_LOCK'.   GT_PROFILE_DEF-THRESHOLD = 1.
      WHEN 'ABAP_WP_DIA'.     GT_PROFILE_DEF-THRESHOLD = 1.
      WHEN 'ABAP_WP_BGD'.     GT_PROFILE_DEF-THRESHOLD = 1.
      WHEN 'ABAP_UPD_ERR'.    GT_PROFILE_DEF-THRESHOLD = 10.
      WHEN 'ABAP_SPOOL_PER'.  GT_PROFILE_DEF-THRESHOLD = 90.
      WHEN 'ABAP_DEAD_SESS'.  GT_PROFILE_DEF-THRESHOLD = 1.
      WHEN 'ABAP_BUF_SWAP'.   GT_PROFILE_DEF-THRESHOLD = 1.
      WHEN 'ABAP_MEM_ROLL'.   GT_PROFILE_DEF-THRESHOLD = 90.
      WHEN 'ABAP_MEM_PAGE'.   GT_PROFILE_DEF-THRESHOLD = 90.
      WHEN 'ABAP_MEM_EXTM'.   GT_PROFILE_DEF-THRESHOLD = 90.
      WHEN 'ABAP_MEM_EXTG'.   GT_PROFILE_DEF-THRESHOLD = 90.
      WHEN 'ABAP_MEM_SHRO'.   GT_PROFILE_DEF-THRESHOLD = 90.
      WHEN 'ABAP_MEM_HEAP'.   GT_PROFILE_DEF-THRESHOLD = 90.
      WHEN 'ABAP_TRFC_ERR'.   GT_PROFILE_DEF-THRESHOLD = 100.
      WHEN 'ABAP_QRFC_OERR'.  GT_PROFILE_DEF-THRESHOLD = 10.
      WHEN 'ABAP_QRFC_IERR'.  GT_PROFILE_DEF-THRESHOLD = 10.
    ENDCASE.

    APPEND GT_PROFILE_DEF. CLEAR: GT_PROFILE_DEF.

  ENDLOOP.

ENDFORM.

*&---------------------------------------------------------------------*
*&      Form  MONI_COLLECT_DATA_RFC
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_TM_OUTTAB  text
*      -->P_LV_SUBRC  text
*----------------------------------------------------------------------*
FORM MONI_COLLECT_DATA_RFC.

  DATA: LV_TEXT TYPE STRING.

  CLEAR  : GT_MONI_DATA. REFRESH: GT_MONI_DATA.

  LOOP AT GV_SID.

    CLEAR  : GT_COLL_DATA, LV_TEXT. REFRESH: GT_COLL_DATA.

    IF GV_SID-RFCSID(3) = SY-SYSID.
      CALL FUNCTION 'ZBC_MONI_COLLECT'
        TABLES
           MONI_RESULT = GT_COLL_DATA.

    ELSEIF GV_SID-RFCSID(3) <> SY-SYSID.
      CALL FUNCTION 'ZBC_MONI_COLLECT'
        DESTINATION GV_SID-RFCSID
        TABLES
          MONI_RESULT = GT_COLL_DATA
        EXCEPTIONS
          SYSTEM_FAILURE        = 1
          COMMUNICATION_FAILURE = 2
          OTHERS                = 3.

    ENDIF.

    IF SY-SUBRC = 0.

      READ TABLE GT_COLL_DATA INDEX 1.
      MOVE-CORRESPONDING GT_COLL_DATA TO GT_MONI_DATA.
      GT_MONI_DATA-REPORT_DATE = SY-DATUM.
      GT_MONI_DATA-REPORT_TIME = SY-UZEIT.
      GT_MONI_DATA-REPORT_USER = SY-UNAME.

      APPEND GT_MONI_DATA. CLEAR: GT_MONI_DATA.

      MODIFY ZBC_MONI_DATA FROM TABLE GT_MONI_DATA.

      CONCATENATE '[' GV_SID-RFCSID(3) '] RFC Monitoring Data Collect Successful' INTO LV_TEXT.
      MESSAGE LV_TEXT TYPE 'S'.

    ELSE.

      CONCATENATE '[' GV_SID-RFCSID(3) '] RFC Monitoring Data Collect Failed' INTO LV_TEXT.
      MESSAGE LV_TEXT TYPE 'I'.

    ENDIF.

  ENDLOOP.

  IF LINES( GV_SID ) = LINES( GT_MONI_DATA ).
    MESSAGE 'ALL SYSTEM - RFC Monitoring Data Collect Successful' TYPE 'S'.

  ENDIF.

ENDFORM.                    " MONI_COLLECT_DATA_RFC

*&---------------------------------------------------------------------*
*&      Form  EVALUTAION_MONI_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM EVALUTAION_MONI_DATA .

  DATA: TEMP_OBJECT(30) TYPE C,
        TEMP_SIGN(30)   TYPE C,
        TEMP_DATE       TYPE D.

  FIELD-SYMBOLS: <fs_object>, <fs_sign>.

  LOOP AT GT_MONI_DATA.

    PERFORM PROFILE_DEFINION USING GT_MONI_DATA-SYS_SID.

    LOOP AT GT_PROFILE_DEF.

      "### 시스템 기본 정보 건너뛰기
      IF GT_PROFILE_DEF-OBJECT CP 'SYS_*'.
        CONTINUE.
      ENDIF.

      CLEAR: TEMP_OBJECT, TEMP_SIGN.

      CONCATENATE 'GT_MONI_DATA-' GT_PROFILE_DEF-OBJECT  INTO TEMP_OBJECT.
      ASSIGN (TEMP_OBJECT) TO <fs_object>.

      CONCATENATE 'GT_DATA-' GT_PROFILE_DEF-OBJECT '_S' INTO TEMP_SIGN.
      ASSIGN (TEMP_SIGN) TO <fs_sign>.

      "### AP 숫자 확인 항목은 비교값이 같아야 정상이므로 별도 평가
      IF GT_PROFILE_DEF-OBJECT = 'AP_COUNT'.
        IF GT_PROFILE_DEF-THRESHOLD > <fs_object>.
          <fs_sign> = '@5C@'.
        ELSE.
          <fs_sign> = '@5B@'.
        ENDIF.
        CONTINUE.
      ENDIF.

      "### 파일시스템 항목은 리턴값이 X 이므로 평가 불필요
      IF GT_PROFILE_DEF-OBJECT = 'OS_FSY_STATE'
        OR GT_PROFILE_DEF-OBJECT = 'ABAP_UPD_STATE'.
        IF <fs_object> = 'X'.
          <fs_sign> = '@5C@'.
        ELSE.
          <fs_sign> = '@5B@'.
        ENDIF.
        CONTINUE.
      ENDIF.

      "### DB BACKUP 항목은 리턴값이 최종백업성공일 이므로 별도 평가
      IF GT_PROFILE_DEF-OBJECT = 'DB_BACKUP'.
        TEMP_DATE  = <fs_object>+0(8).
        IF GT_PROFILE_DEF-THRESHOLD < ( SY-DATUM - TEMP_DATE ).
          <fs_sign> = '@5C@'.
        ELSE.
          <fs_sign> = '@5B@'.
        ENDIF.
        CONTINUE.
      ENDIF.

      "### 평가 PROFILE 에 따라 모니터링 항목 평가
      IF GT_PROFILE_DEF-TYPE = 1 AND <fs_sign> IS INITIAL.
        IF GT_PROFILE_DEF-THRESHOLD <= <fs_object>.
          <fs_sign> = '@5D@'.
        ELSE.
          <fs_sign> = '@5B@'.
        ENDIF.
      ELSEIF GT_PROFILE_DEF-TYPE = 2.
        IF GT_PROFILE_DEF-THRESHOLD <= <fs_object>.
          <fs_sign> = '@5C@'.
        ELSE.
          <fs_sign> = '@5B@'.
        ENDIF.
      ENDIF.


      "### 평가 불필요 항목에 대해 평가값 INACTIVE
      "### Oracle DB 시스템은 HDB 항목 평가 불필요
      IF GT_PROFILE_DEF-OBJECT CP 'DB_ORA_*'.
        IF GT_MONI_DATA-SYS_DB <> 'ORACLE'.
          <fs_sign> = '@BZ@'.
        ENDIF.
      ENDIF.

      "### HANA DB 시스템은 Oracle 항목 평가 불필요
      IF GT_PROFILE_DEF-OBJECT CP 'DB_HDB_*'.
        IF GT_MONI_DATA-SYS_DB <> 'HDB'.
          <fs_sign> = '@BZ@'.
        ENDIF.
      ENDIF.

      "### 수집값이 -1 (0 미만) 일 경우, 평가 불필요 항목 하드코딩
      IF <fs_object> < 0.
        <fs_sign> = '@BZ@'.
      ENDIF.

      "### Filesystem 과 System Log 는 미지원
      IF GT_PROFILE_DEF-OBJECT = 'OS_FSY_STATE'.
        <fs_sign> = '@BZ@'.
      ENDIF.

    ENDLOOP.

    MOVE-CORRESPONDING GT_MONI_DATA TO GT_DATA.
    APPEND GT_DATA. CLEAR:GT_DATA.

  ENDLOOP.

ENDFORM.

*&---------------------------------------------------------------------*
*&      Form  PROFILE_DEFINION
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM PROFILE_DEFINION USING P_SID.

  CLEAR: GT_PROFILE. REFRESH: GT_PROFILE.

  PERFORM SET_DEAFULT_PROFILE USING P_SID.

  SELECT * INTO CORRESPONDING FIELDS OF TABLE GT_PROFILE
    FROM ZBC_MONI_PROFILE
    WHERE SID = P_SID.

  "### PROFILE TYPE 1 추가 - Default Profile 에 TYPE 1은 없기 떄문에, 별도 추가.
  LOOP AT GT_PROFILE WHERE TYPE = 1.

    CLEAR: GT_PROFILE_DEF.

    GT_PROFILE_DEF-SID = P_SID.
    GT_PROFILE_DEF-TYPE = 1.
    GT_PROFILE_DEF-OBJECT = GT_PROFILE-OBJECT.
    GT_PROFILE_DEF-THRESHOLD = GT_PROFILE-THRESHOLD.

    APPEND GT_PROFILE_DEF. CLEAR: GT_PROFILE_DEF.

  ENDLOOP.

  "### PROFILE TYPE 2 값 변경
  LOOP AT GT_PROFILE_DEF.

    "### PROFILE TYPE 2 값 변경
    READ TABLE GT_PROFILE WITH KEY OBJECT = GT_PROFILE_DEF-OBJECT
                                   TYPE   = 2.

    IF SY-SUBRC = 0.

      GT_PROFILE_DEF-THRESHOLD = GT_PROFILE-THRESHOLD.

      MODIFY GT_PROFILE_DEF.

    ENDIF.

  ENDLOOP.

  "SORT GT_PROFILE_DEF BY SID TYPE.

ENDFORM.

*&---------------------------------------------------------------------*
*&      Form  RESULT_VIEW
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_GT_DATA  text
*----------------------------------------------------------------------*
FORM RESULT_VIEW  TABLES P_GT_DATA .

  DATA: LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
        LT_LAYOUT   TYPE SLIS_LAYOUT_ALV,
        LT_EVENT    TYPE SLIS_T_EVENT.

  "### ALV Field Catalog 설정 (Table 에 맞게 순서와 너비 등등을 설정)
  LT_FIELDCAT-FIELDNAME   = 'REPORT_DATE'.
  LT_FIELDCAT-SELTEXT_M   = 'DATE'.
  LT_FIELDCAT-KEY         = 'X'.
  LT_FIELDCAT-OUTPUTLEN   = 10.
  LT_FIELDCAT-COL_POS     = 0.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'REPORT_TIME'.
  LT_FIELDCAT-SELTEXT_M   = 'TIME'.
  LT_FIELDCAT-KEY         = 'X'.
  LT_FIELDCAT-OUTPUTLEN   = 8.
  LT_FIELDCAT-COL_POS     = 1.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'SYS_SID'.
  LT_FIELDCAT-SELTEXT_M   = 'SID'.
  LT_FIELDCAT-KEY         = 'X'.
  LT_FIELDCAT-OUTPUTLEN   = 4.
  LT_FIELDCAT-COL_POS     = 2.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'SYS_OS'.
  LT_FIELDCAT-SELTEXT_M   = 'OS'.
  LT_FIELDCAT-OUTPUTLEN   = 8.
  LT_FIELDCAT-COL_POS     = 3.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'SYS_DB'.
  LT_FIELDCAT-SELTEXT_M   = 'DB'.
  LT_FIELDCAT-OUTPUTLEN   = 8.
  LT_FIELDCAT-COL_POS     = 4.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'SYS_HOSTNAME'.
  LT_FIELDCAT-SELTEXT_M   = 'HostName'.
  LT_FIELDCAT-OUTPUTLEN   = 12.
  LT_FIELDCAT-COL_POS     = 5.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'SYS_KERNEL'.
  LT_FIELDCAT-SELTEXT_M   = 'SAP Kernel'.
  LT_FIELDCAT-OUTPUTLEN   = 20.
  LT_FIELDCAT-COL_POS     = 6.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'SYS_BASIS'.
  LT_FIELDCAT-SELTEXT_M   = 'SAP BASIS'.
  LT_FIELDCAT-OUTPUTLEN   = 10.
  LT_FIELDCAT-COL_POS     = 7.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'AP_COUNT_S'.
  LT_FIELDCAT-SELTEXT_M   = 'AP Cnt'.
  LT_FIELDCAT-SELTEXT_L   = 'AP Total Count'.
  LT_FIELDCAT-OUTPUTLEN   = 7.
  LT_FIELDCAT-COL_POS     = 8.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'AP_STATE_S'.
  LT_FIELDCAT-SELTEXT_M   = 'AP Act.'.
  LT_FIELDCAT-SELTEXT_L   = 'AP Inact Count'.
  LT_FIELDCAT-OUTPUTLEN   = 6.
  LT_FIELDCAT-COL_POS     = 9.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'OS_CPU_USED_S'.
  LT_FIELDCAT-SELTEXT_M   = 'OS CPU'.
  LT_FIELDCAT-SELTEXT_L   = 'OS CPU Usage (%)'.
  LT_FIELDCAT-OUTPUTLEN   = 7.
  LT_FIELDCAT-COL_POS     = 10.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'OS_CPU_5AVG_S'.
  LT_FIELDCAT-SELTEXT_M   = 'OS 5AVG'.
  LT_FIELDCAT-SELTEXT_L   = 'OS CPU 5Avg. Load'.
  LT_FIELDCAT-OUTPUTLEN   = 7.
  LT_FIELDCAT-COL_POS     = 11.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'OS_MEM_USED_S'.
  LT_FIELDCAT-SELTEXT_M   = 'OS MEM'.
  LT_FIELDCAT-SELTEXT_L   = 'OS Memory Usage (%)'.
  LT_FIELDCAT-OUTPUTLEN   = 7.
  LT_FIELDCAT-COL_POS     = 12.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'OS_MEM_SWAP_S'.
  LT_FIELDCAT-SELTEXT_M   = 'OS SWAP'.
  LT_FIELDCAT-SELTEXT_L   = 'OS SWAP Usage (%)'.
  LT_FIELDCAT-OUTPUTLEN   = 7.
  LT_FIELDCAT-COL_POS     = 13.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'DB_BACKUP_S'.
  LT_FIELDCAT-SELTEXT_M   = 'DB BKUP'.
  LT_FIELDCAT-SELTEXT_L   = 'DB Last Successful Backup Interval'.
  LT_FIELDCAT-OUTPUTLEN   = 7.
  LT_FIELDCAT-COL_POS     = 14.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'DB_ORA_SR3_USED_S'.
  LT_FIELDCAT-SELTEXT_M   = 'ORA SR3'.
  LT_FIELDCAT-SELTEXT_L   = 'DB Oracle PSAPSR3 Usage (%)'.
  LT_FIELDCAT-OUTPUTLEN   = 7.
  LT_FIELDCAT-COL_POS     = 15.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'DB_ORA_USR_USED_S'.
  LT_FIELDCAT-SELTEXT_M   = 'ORA USR'.
  LT_FIELDCAT-SELTEXT_L   = 'DB Oracle PSAPSR3USR Usage (%)'.
  LT_FIELDCAT-OUTPUTLEN   = 7.
  LT_FIELDCAT-COL_POS     = 16.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'DB_HDB_MEM_USED_S'.
  LT_FIELDCAT-SELTEXT_M   = 'HDB MEM'.
  LT_FIELDCAT-SELTEXT_L   = 'DB HANA Memory Usage (%)'.
  LT_FIELDCAT-OUTPUTLEN   = 7.
  LT_FIELDCAT-COL_POS     = 17.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'DB_HDB_DIS_USED_S'.
  LT_FIELDCAT-SELTEXT_M   = 'HDB DIS'.
  LT_FIELDCAT-SELTEXT_L   = 'DB HANA Disk Usage (%)'.
  LT_FIELDCAT-OUTPUTLEN   = 7.
  LT_FIELDCAT-COL_POS     = 18.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'DB_DBA_ERROR_S'.
  LT_FIELDCAT-SELTEXT_M   = 'DBA JOB'.
  LT_FIELDCAT-SELTEXT_L   = 'DB DBA Job Failed Count'.
  LT_FIELDCAT-OUTPUTLEN   = 7.
  LT_FIELDCAT-COL_POS     = 19.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'DB_LOCK_ERROR_S'.
  LT_FIELDCAT-SELTEXT_M   = 'DB LCK'.
  LT_FIELDCAT-SELTEXT_L   = 'DB Lock Count'.
  LT_FIELDCAT-OUTPUTLEN   = 7.
  LT_FIELDCAT-COL_POS     = 20.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'DB_ALERT_COUNT_S'.
  LT_FIELDCAT-SELTEXT_M   = 'DB ALT'.
  LT_FIELDCAT-SELTEXT_L   = 'DB Alert Count'.
  LT_FIELDCAT-OUTPUTLEN   = 7.
  LT_FIELDCAT-COL_POS     = 21.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'ABAP_BTC_AERR_S'.
  LT_FIELDCAT-SELTEXT_M   = 'BTC ALL'.
  LT_FIELDCAT-SELTEXT_L   = 'ABAP All BatchJob Error Count'.
  LT_FIELDCAT-OUTPUTLEN   = 7.
  LT_FIELDCAT-COL_POS     = 22.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'ABAP_BTC_SERR_S'.
  LT_FIELDCAT-SELTEXT_M   = 'BTC STD'.
  LT_FIELDCAT-SELTEXT_L   = 'ABAP Standard BatchJob Error Count'.
  LT_FIELDCAT-OUTPUTLEN   = 7.
  LT_FIELDCAT-COL_POS     = 23.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'ABAP_BTC_ZERR_S'.
  LT_FIELDCAT-SELTEXT_M   = 'BTC Z'.
  LT_FIELDCAT-SELTEXT_L   = 'ABAP ZCBO BatchJob Error Count'.
  LT_FIELDCAT-OUTPUTLEN   = 7.
  LT_FIELDCAT-COL_POS     = 24.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'ABAP_DUMP_COUNT_S'.
  LT_FIELDCAT-SELTEXT_M   = 'DUMP'.
  LT_FIELDCAT-SELTEXT_L   = 'ABAP Dump Count'.
  LT_FIELDCAT-OUTPUTLEN   = 7.
  LT_FIELDCAT-COL_POS     = 25.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'ABAP_ENQ_LOCK_S'.
  LT_FIELDCAT-SELTEXT_M   = 'ABAP LK'.
  LT_FIELDCAT-SELTEXT_L   = 'ABAP ENQ LOCK Count'.
  LT_FIELDCAT-OUTPUTLEN   = 7.
  LT_FIELDCAT-COL_POS     = 26.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'ABAP_WP_DIA_S'.
  LT_FIELDCAT-SELTEXT_M   = 'WP DIA'.
  LT_FIELDCAT-SELTEXT_L   = 'ABAP Over-running DIA Count'.
  LT_FIELDCAT-OUTPUTLEN   = 7.
  LT_FIELDCAT-COL_POS     = 27.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'ABAP_WP_BGD_S'.
  LT_FIELDCAT-SELTEXT_M   = 'WP BGD'.
  LT_FIELDCAT-SELTEXT_L   = 'ABAP Over-running BGD Count'.
  LT_FIELDCAT-OUTPUTLEN   = 7.
  LT_FIELDCAT-COL_POS     = 28.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'ABAP_UPD_STATE_S'.
  LT_FIELDCAT-SELTEXT_M   = 'UPD St'.
  LT_FIELDCAT-SELTEXT_L   = 'ABAP Update System Status'.
  LT_FIELDCAT-OUTPUTLEN   = 7.
  LT_FIELDCAT-COL_POS     = 29.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'ABAP_UPD_ERR_S'.
  LT_FIELDCAT-SELTEXT_M   = 'UPD Req'.
  LT_FIELDCAT-SELTEXT_L   = 'ABAP Update Request Failed Count'.
  LT_FIELDCAT-OUTPUTLEN   = 7.
  LT_FIELDCAT-COL_POS     = 30.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'ABAP_DEAD_SESS_S'.
  LT_FIELDCAT-SELTEXT_M   = 'D Sess'.
  LT_FIELDCAT-SELTEXT_L   = 'ABAP Dead Session Count'.
  LT_FIELDCAT-OUTPUTLEN   = 7.
  LT_FIELDCAT-COL_POS     = 31.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'ABAP_BUF_SWAP_S'.
  LT_FIELDCAT-SELTEXT_M   = 'BUF SWP'.
  LT_FIELDCAT-SELTEXT_L   = 'ABAP SWAP Used Buffer Count'.
  LT_FIELDCAT-OUTPUTLEN   = 7.
  LT_FIELDCAT-COL_POS     = 32.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'ABAP_MEM_ROLL_S'.
  LT_FIELDCAT-SELTEXT_M   = 'M ROLL'.
  LT_FIELDCAT-SELTEXT_L   = 'ABAP ROLL Memory MaxUsage (%)'.
  LT_FIELDCAT-OUTPUTLEN   = 7.
  LT_FIELDCAT-COL_POS     = 33.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'ABAP_MEM_PAGE_S'.
  LT_FIELDCAT-SELTEXT_M   = 'M PAGE'.
  LT_FIELDCAT-SELTEXT_L   = 'ABAP RAGE Memory MaxUsage (%)'.
  LT_FIELDCAT-OUTPUTLEN   = 7.
  LT_FIELDCAT-COL_POS     = 34.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'ABAP_MEM_EXTM_S'.
  LT_FIELDCAT-SELTEXT_M   = 'M EXTM'.
  LT_FIELDCAT-SELTEXT_L   = 'ABAP EXTM Memory MaxUsage (%)'.
  LT_FIELDCAT-OUTPUTLEN   = 7.
  LT_FIELDCAT-COL_POS     = 35.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'ABAP_MEM_EXTG_S'.
  LT_FIELDCAT-SELTEXT_M   = 'M EXTG'.
  LT_FIELDCAT-SELTEXT_L   = 'ABAP EXTG Memory MaxUsage (%)'.
  LT_FIELDCAT-OUTPUTLEN   = 7.
  LT_FIELDCAT-COL_POS     = 36.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'ABAP_MEM_SHRO_S'.
  LT_FIELDCAT-SELTEXT_M   = 'M SHRO'.
  LT_FIELDCAT-SELTEXT_L   = 'ABAP SHRO Memory MaxUsage (%)'.
  LT_FIELDCAT-OUTPUTLEN   = 7.
  LT_FIELDCAT-COL_POS     = 37.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'ABAP_MEM_HEAP_S'.
  LT_FIELDCAT-SELTEXT_M   = 'M HEAP'.
  LT_FIELDCAT-SELTEXT_L   = 'ABAP HEAP Memory MaxUsage (%)'.
  LT_FIELDCAT-OUTPUTLEN   = 7.
  LT_FIELDCAT-COL_POS     = 38.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'ABAP_TRFC_ERR_S'.
  LT_FIELDCAT-SELTEXT_M   = 'tRFC'.
  LT_FIELDCAT-SELTEXT_L   = 'ABAP tRFC Failed Count'.
  LT_FIELDCAT-OUTPUTLEN   = 7.
  LT_FIELDCAT-COL_POS     = 39.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'ABAP_QRFC_OERR_S'.
  LT_FIELDCAT-SELTEXT_M   = 'qRFC OT'.
  LT_FIELDCAT-SELTEXT_L   = 'ABAP qRFC OutBound Failed Count'.
  LT_FIELDCAT-OUTPUTLEN   = 7.
  LT_FIELDCAT-COL_POS     = 40.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'ABAP_QRFC_IERR_S'.
  LT_FIELDCAT-SELTEXT_M   = 'qRFC IN'.
  LT_FIELDCAT-SELTEXT_L   = 'ABAP qRFC InBound Failed Count'.
  LT_FIELDCAT-OUTPUTLEN   = 7.
  LT_FIELDCAT-COL_POS     = 41.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.


  "### ALV Layout 설정
  LT_LAYOUT-BOX_FIELDNAME = 'SEL'.
*  LT_LAYOUT-INFO_FIELDNAME = 'LINECOLOR'.
*  LT_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
  LT_LAYOUT-ZEBRA = 'X'.
  LT_LAYOUT-BOX_TABNAME = 'P_GT_DATA'.

  "### 위에 설정된 Field Catalog 와 Layout 을 사용하여 ALV 리스트 출력 펑션 콜
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_CALLBACK_PROGRAM       = SY-REPID
      I_CALLBACK_USER_COMMAND  = 'USER_COMMAND'
      I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
      "I_GRID_TITLE             = GV_ALV_HEADER
      I_CALLBACK_TOP_OF_PAGE   = 'TOP-OF-PAGE'
      IT_FIELDCAT              = LT_FIELDCAT[]
      IS_LAYOUT                = LT_LAYOUT
*      I_SAVE = 'A'
    TABLES
      T_OUTTAB = P_GT_DATA.

ENDFORM.

*------------------------------------------------------------------*
* FORM SET_PF_STATUS
*------------------------------------------------------------------*
FORM SET_PF_STATUS  USING PI_EXTAB    TYPE SLIS_T_EXTAB.

  DATA: BEGIN OF LT_EXCL OCCURS 0,
          MENU(20)        TYPE C.
  DATA: END OF LT_EXCL.

  REFRESH: LT_EXCL. CLEAR: LT_EXCL.

  IF SY-UCOMM IS INITIAL.

    LT_EXCL-MENU = 'ADD_PROF'.  APPEND LT_EXCL.

    SET PF-STATUS 'S100' EXCLUDING LT_EXCL.

  ELSEIF SY-UCOMM = 'FC02'.

    LT_EXCL-MENU = 'REPORT'.  APPEND LT_EXCL.

    SET PF-STATUS 'S100' EXCLUDING LT_EXCL.

  ENDIF.

ENDFORM.

*------------------------------------------------------------------*
* FORM USER_COMMAND
*------------------------------------------------------------------*
FORM USER_COMMAND  USING PI_UCOMM    LIKE SY-UCOMM
                          PI_SELFIELD TYPE SLIS_SELFIELD.

  CASE PI_UCOMM.

    "### UserCommand_Double Click
    WHEN '&IC1'.        " SAP standard code for double-clicking

    "### UserCommand_BACK/EXIT/CANC
    WHEN 'BACK' OR 'EXIT' OR 'CANC'.

      LEAVE TO SCREEN 0.

    WHEN 'REPORT'.

      PERFORM REPORT_BUILD.

    WHEN 'ADD_PROF'.

      PERFORM ADD_PROFILE.

  ENDCASE.

  "### ALV 리프레시 설정
  PI_SELFIELD-REFRESH = 'X'.
  PI_SELFIELD-COL_STABLE = 'X'.
  PI_SELFIELD-ROW_STABLE = 'X'.

ENDFORM.

*-------------------------------------------------------------------*
* Form  TOP-OF-PAGE                                                 *
*-------------------------------------------------------------------*
* ALV Report Header                                                 *
*-------------------------------------------------------------------*
FORM TOP-OF-PAGE.

*ALV Header declarations
  DATA: T_HEADER  TYPE SLIS_T_LISTHEADER,
        WA_HEADER TYPE SLIS_LISTHEADER.

  DATA: LV_TEXT(30)     TYPE C,
        START_DATE(10)  TYPE C,
        END_DATE(10)    TYPE C.

  "### 여백 라인 삽입
  WA_HEADER-TYP  = 'S'.
  WA_HEADER-INFO = ''.
  APPEND WA_HEADER TO T_HEADER.
  CLEAR WA_HEADER.

  WA_HEADER-TYP  = 'H'.
  WA_HEADER-INFO = 'Daily Monitoring Evaluation Metrics'.
  APPEND WA_HEADER TO T_HEADER.
  CLEAR WA_HEADER.

  CLEAR: LV_TEXT.

  IF P_SID = '%'. P_SID = 'ALL'. ENDIF.
  CONCATENATE 'SID : ' P_SID INTO LV_TEXT SEPARATED BY SPACE.

  WA_HEADER-TYP  = 'S'.
  WA_HEADER-INFO = LV_TEXT.
  APPEND WA_HEADER TO T_HEADER.
  CLEAR: WA_HEADER.

  IF S_DATE IS NOT INITIAL.

    CLEAR: LV_TEXT.

    CONCATENATE S_DATE-LOW+0(4) '.' S_DATE-LOW+4(2) '.' S_DATE-LOW+6(2)     INTO START_DATE.
    CONCATENATE S_DATE-HIGH+0(4) '.' S_DATE-HIGH+4(2) '.' S_DATE-HIGH+6(2)  INTO END_DATE.

    CONCATENATE 'Date : ' START_DATE '~' END_DATE INTO LV_TEXT SEPARATED BY SPACE.

    WA_HEADER-TYP  = 'S'.
    WA_HEADER-INFO = LV_TEXT.
    APPEND WA_HEADER TO T_HEADER.
    CLEAR: WA_HEADER.

  ENDIF.

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      IT_LIST_COMMENTARY = T_HEADER.

ENDFORM.                    "TOP-OF-PAGE.

*&---------------------------------------------------------------------*
*&      Form  SELECT_MONI_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM SELECT_MONI_DATA .

  IF P_SID IS INITIAL.
    P_SID = '%'.
  ENDIF.

  IF S_DATE IS INITIAL.

    SELECT * INTO CORRESPONDING FIELDS OF TABLE GT_MONI_DATA
      FROM ZBC_MONI_DATA
      WHERE SYS_SID LIKE P_SID.

  ELSE.

    SELECT * INTO CORRESPONDING FIELDS OF TABLE GT_MONI_DATA
      FROM ZBC_MONI_DATA
      WHERE SYS_SID LIKE P_SID
        AND REPORT_DATE IN S_DATE.

  ENDIF.

ENDFORM.

*&---------------------------------------------------------------------*
*&      Form  REPORT_BUILD
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM REPORT_BUILD .

  DATA: LT_REPORT_STR LIKE TABLE OF DD03L WITH HEADER LINE.
  DATA: TEMP_VAL(30)    TYPE C,
        TEMP_RSIGN(30)  TYPE C,
        TEMP_COUNT(1)   TYPE N.

  FIELD-SYMBOLS: <fs_val>, <fs_rsign>.

  "### 선택한 행이 몇 개인지 확인. 1개만 가능
  LOOP AT GT_DATA WHERE SEL = 'X'.
    TEMP_COUNT = TEMP_COUNT + 1.
  ENDLOOP.

  IF TEMP_COUNT = 1.

    CLEAR: GT_REPORT. REFRESH: GT_REPORT.

    SELECT FIELDNAME POSITION INTO CORRESPONDING FIELDS OF TABLE LT_REPORT_STR
      FROM DD03L
      WHERE TABNAME = 'ZBC_MONI_DATA'.

    SORT LT_REPORT_STR BY POSITION.

    PERFORM PROFILE_DEFINION USING GT_DATA-SYS_SID.

    LOOP AT LT_REPORT_STR.

      "### Filesystem 체크 미지원
      IF LT_REPORT_STR-FIELDNAME = 'OS_FSY_STATE'.
        CONTINUE.
      ENDIF.

      CLEAR: TEMP_VAL, TEMP_RSIGN.
      CONCATENATE 'GT_DATA-' LT_REPORT_STR-FIELDNAME INTO TEMP_VAL.
      ASSIGN (TEMP_VAL) TO <fs_val>.

      CONCATENATE 'GT_DATA-' LT_REPORT_STR-FIELDNAME '_S' INTO TEMP_RSIGN.
      ASSIGN (TEMP_RSIGN) TO <fs_rsign>.

      GT_REPORT-R_OBJECT = LT_REPORT_STR-FIELDNAME.
      GT_REPORT-R_VALUE = <fs_val>.

      READ TABLE GT_PROFILE_DEF WITH KEY OBJECT = LT_REPORT_STR-FIELDNAME
                                         TYPE   = 1.

      IF SY-SUBRC = 0.
        GT_REPORT-R_PROFILE1 = GT_PROFILE_DEF-THRESHOLD.

      ELSE.
        GT_REPORT-R_PROFILE1 = '-'.

      ENDIF.

      READ TABLE GT_PROFILE_DEF WITH KEY OBJECT = LT_REPORT_STR-FIELDNAME
                                         TYPE   = 2.

      IF SY-SUBRC = 0.
        GT_REPORT-R_PROFILE2 = GT_PROFILE_DEF-THRESHOLD.
        IF GT_PROFILE_DEF-THRESHOLD = 0. GT_REPORT-R_PROFILE2 = '-'. ENDIF.

      ELSE.
        GT_REPORT-R_PROFILE2 = '-'.

      ENDIF.

      GT_REPORT-R_EVAL = <fs_rsign>.

      IF GT_REPORT-R_EVAL = '@5D@'.
        GT_REPORT-LINECOLOR = 'C300'.

      ELSEIF GT_REPORT-R_EVAL = '@5C@'.
        GT_REPORT-LINECOLOR = 'C600'.

      ELSEIF GT_REPORT-R_EVAL = '@BZ@'.
        GT_REPORT-LINECOLOR = 'C000'.

      ENDIF.


      APPEND GT_REPORT. CLEAR: GT_REPORT.

    ENDLOOP.

  ELSE.

    MESSAGE 'Choose 1 row.' TYPE 'S'.

  ENDIF.

  PERFORM REPORT_VIEW TABLES GT_REPORT.


ENDFORM.

*&---------------------------------------------------------------------*
*&      Form  REPORT_VIEW
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_GT_DATA  text
*----------------------------------------------------------------------*
FORM REPORT_VIEW  TABLES P_GT_DATA .

  DATA: LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
        LT_LAYOUT   TYPE SLIS_LAYOUT_ALV,
        LT_EVENT    TYPE SLIS_T_EVENT.

  "### ALV Field Catalog 설정 (Table 에 맞게 순서와 너비 등등을 설정)
  LT_FIELDCAT-FIELDNAME   = 'R_OBJECT'.
  LT_FIELDCAT-SELTEXT_M   = 'Item'.
  LT_FIELDCAT-KEY         = 'X'.
  LT_FIELDCAT-OUTPUTLEN   = 20.
  LT_FIELDCAT-COL_POS     = 0..
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'R_VALUE'.
  LT_FIELDCAT-SELTEXT_M   = 'Value'.
  LT_FIELDCAT-OUTPUTLEN   = 20.
  LT_FIELDCAT-COL_POS     = 1.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.


  LT_FIELDCAT-FIELDNAME   = 'R_PROFILE1'.
  LT_FIELDCAT-SELTEXT_M   = 'Warn'.
  LT_FIELDCAT-OUTPUTLEN   = 5.
  LT_FIELDCAT-COL_POS     = 2.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'R_PROFILE2'.
  LT_FIELDCAT-SELTEXT_M   = 'Crit'.
  LT_FIELDCAT-OUTPUTLEN   = 5.
  LT_FIELDCAT-COL_POS     = 3.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'R_EVAL'.
  LT_FIELDCAT-SELTEXT_M   = 'Eval'.
  LT_FIELDCAT-OUTPUTLEN   = 4.
  LT_FIELDCAT-COL_POS     = 4.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.


  "### ALV Layout 설정
  LT_LAYOUT-BOX_FIELDNAME = 'SEL'.
  LT_LAYOUT-INFO_FIELDNAME = 'LINECOLOR'.
*  LT_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
  LT_LAYOUT-ZEBRA = 'X'.
  LT_LAYOUT-BOX_TABNAME = 'P_GT_DATA'.

  "### 위에 설정된 Field Catalog 와 Layout 을 사용하여 ALV 리스트 출력 펑션 콜
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_CALLBACK_PROGRAM       = SY-REPID
      "I_CALLBACK_USER_COMMAND  = 'USER_COMMAND'
      "I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
      "I_GRID_TITLE             = GV_ALV_HEADER
      "I_CALLBACK_TOP_OF_PAGE   = 'TOP-OF-PAGE'
      IT_FIELDCAT              = LT_FIELDCAT[]
      IS_LAYOUT                = LT_LAYOUT
*      I_SAVE = 'A'
    TABLES
      T_OUTTAB = P_GT_DATA.

ENDFORM.

*&---------------------------------------------------------------------*
*&      Form  PROFILE_VIEW
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM PROFILE_VIEW.

  DATA: LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
        LT_LAYOUT   TYPE SLIS_LAYOUT_ALV,
        LT_EVENT    TYPE SLIS_T_EVENT.

  DATA: BEGIN OF LT_PROFILE OCCURS 0,
          SEL(1)        TYPE C.
          INCLUDE STRUCTURE ZBC_MONI_PROFILE.
  DATA: END OF LT_PROFILE.

  SELECT * INTO CORRESPONDING FIELDS OF TABLE LT_PROFILE
    FROM ZBC_MONI_PROFILE.

  SORT LT_PROFILE BY SID TYPE.

  "### ALV Field Catalog 설정 (Table 에 맞게 순서와 너비 등등을 설정)
  LT_FIELDCAT-FIELDNAME   = 'SID'.
  LT_FIELDCAT-SELTEXT_M   = 'SID'.
  LT_FIELDCAT-KEY         = 'X'.
  LT_FIELDCAT-OUTPUTLEN   = 5.
  LT_FIELDCAT-COL_POS     = 0.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'TYPE'.
  LT_FIELDCAT-SELTEXT_M   = 'TYPE'.
  LT_FIELDCAT-KEY         = 'X'.
  LT_FIELDCAT-OUTPUTLEN   = 5.
  LT_FIELDCAT-COL_POS     = 1.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.


  LT_FIELDCAT-FIELDNAME   = 'OBJECT'.
  LT_FIELDCAT-SELTEXT_M   = 'OBJECT'.
  LT_FIELDCAT-KEY         = 'X'.
  LT_FIELDCAT-OUTPUTLEN   = 20.
  LT_FIELDCAT-COL_POS     = 2.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.

  LT_FIELDCAT-FIELDNAME   = 'THRESHOLD'.
  LT_FIELDCAT-SELTEXT_M   = 'VAL'.
  LT_FIELDCAT-OUTPUTLEN   = 5.
  LT_FIELDCAT-COL_POS     = 3.
  LT_FIELDCAT-JUST        = 'C'.
  APPEND LT_FIELDCAT. CLEAR  LT_FIELDCAT.


  "### ALV Layout 설정
  LT_LAYOUT-BOX_FIELDNAME = 'SEL'.
*  LT_LAYOUT-INFO_FIELDNAME = 'LINECOLOR'.
*  LT_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
  LT_LAYOUT-EDIT_MODE = 'X'.
  LT_LAYOUT-ZEBRA = 'X'.
  LT_LAYOUT-BOX_TABNAME = 'LT_PROFILE'.

  "### 위에 설정된 Field Catalog 와 Layout 을 사용하여 ALV 리스트 출력 펑션 콜
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_CALLBACK_PROGRAM       = SY-REPID
      I_CALLBACK_USER_COMMAND  = 'USER_COMMAND'
      I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
      "I_GRID_TITLE             = GV_ALV_HEADER
      "I_CALLBACK_TOP_OF_PAGE   = 'TOP-OF-PAGE'
      IT_FIELDCAT              = LT_FIELDCAT[]
      IS_LAYOUT                = LT_LAYOUT
*      I_SAVE = 'A'
    TABLES
      T_OUTTAB = LT_PROFILE.

ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  ADD_PROFILE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM ADD_PROFILE .

  DATA: IT_FIELDS LIKE SVAL OCCURS 0 WITH HEADER LINE.
  DATA: PROFILE_DATA LIKE TABLE OF ZBC_MONI_PROFILE WITH HEADER LINE.

  DATA: LT_SUBRC TYPE C.

  "### 신규 시스템 정보를 받아올 팝업 임시 테이블
  IT_FIELDS-TABNAME   = 'ZBC_MONI_PROFILE'.
  IT_FIELDS-FIELDNAME = 'SID'.
  IT_FIELDS-FIELDTEXT = 'SID'.
  IT_FIELDS-FIELD_OBL = 'X'.
  APPEND IT_FIELDS. CLEAR IT_FIELDS.
  IT_FIELDS-TABNAME   = 'ZBC_MONI_PROFILE'.
  IT_FIELDS-FIELDNAME = 'TYPE'.
  IT_FIELDS-FIELDTEXT = 'TYPE'.
  IT_FIELDS-FIELD_OBL = 'X'.
  APPEND IT_FIELDS. CLEAR IT_FIELDS.
  IT_FIELDS-TABNAME   = 'ZBC_MONI_PROFILE'.
  IT_FIELDS-FIELDNAME = 'OBJECT'.
  IT_FIELDS-FIELDTEXT = 'OBJECT'.
  IT_FIELDS-FIELD_OBL = 'X'.
  APPEND IT_FIELDS. CLEAR IT_FIELDS.
  IT_FIELDS-TABNAME   = 'ZBC_MONI_PROFILE'.
  IT_FIELDS-FIELDNAME = 'THRESHOLD'.
  IT_FIELDS-FIELDTEXT = 'THRESHOLD'.
  IT_FIELDS-FIELD_OBL = 'X'.
  APPEND IT_FIELDS. CLEAR IT_FIELDS.

  CALL FUNCTION 'POPUP_GET_VALUES_USER_HELP'
    EXPORTING
      POPUP_TITLE       = 'ADD SYSTEM'
    IMPORTING
      RETURNCODE        = LT_SUBRC
    TABLES
      FIELDS            = IT_FIELDS
    EXCEPTIONS
      ERROR_IN_FIELDS   = 1
      OTHERS            = 2.

  IF LT_SUBRC IS INITIAL.
    READ TABLE IT_FIELDS WITH KEY FIELDNAME = 'SID'.       PROFILE_DATA-SID       = IT_FIELDS-VALUE.
    READ TABLE IT_FIELDS WITH KEY FIELDNAME = 'TYPE'.      PROFILE_DATA-TYPE      = IT_FIELDS-VALUE.
    READ TABLE IT_FIELDS WITH KEY FIELDNAME = 'OBJECT'.    PROFILE_DATA-OBJECT    = IT_FIELDS-VALUE.
    READ TABLE IT_FIELDS WITH KEY FIELDNAME = 'THRESHOLD'. PROFILE_DATA-THRESHOLD = IT_FIELDS-VALUE.

    APPEND PROFILE_DATA.

    MODIFY ZBC_MONI_PROFILE FROM TABLE PROFILE_DATA.

  ENDIF.

ENDFORM.

 


2. RFC Function Module

  • Function Module Name : ZBC_MONI_COLLECT
  • Attributes - Processing Type => Remote-Enable Module
  • TablesParameter NameTypeingAssociated TypeOptionalShort Text
    MONI_RESULT LIKE ZBC_MONI_COLLECT_DATA   -

 

FUNCTION ZBC_MONI_COLLECT.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  TABLES
*"      MONI_RESULT STRUCTURE  ZBC_MONI_COLLECT_DATA
*"----------------------------------------------------------------------

*### 공용 데이터 타입
DATA: TEMP_COUNT(3)  TYPE N,
      TEMP_DATE1     TYPE D,
      TEMP_DATE2     TYPE D,
      TEMP_TIME      TYPE T,
      START_DATE(12) TYPE C,
      END_DATE(12)   TYPE C.

*==================================================================

*### 0. 시스템 기초 데이터 수집

*### SID
MONI_RESULT-SYS_SID = SY-SYSID.

*### OS 종류
MONI_RESULT-SYS_OS = SY-OPSYS.

*### DB 종류
MONI_RESULT-SYS_DB = SY-DBSYS.

*### 현재 인스턴스 호스트네임
MONI_RESULT-SYS_HOSTNAME = SY-HOST.

*### SAP_Kernel 버전
DATA: SYS_KERN(20) TYPE C,
      SYS_KNREL LIKE THLINES-THLINE,
      SYS_KNPL  LIKE THLINES-THLINE.

CALL FUNCTION 'TH_SAPREL'
  IMPORTING
    KERN_REL        = SYS_KNREL
    KERN_PATCHLEVEL = SYS_KNPL.


CONCATENATE SYS_KNREL ' PL_' SYS_KNPL INTO SYS_KERN.

MONI_RESULT-SYS_KERNEL = SYS_KERN.

*### SAP_BASIS 버전
DATA: SYS_COMP LIKE TABLE OF CVERS WITH HEADER LINE.
DATA: SYS_BASIS(20) TYPE C.

SELECT COMPONENT RELEASE EXTRELEASE INTO CORRESPONDING FIELDS OF TABLE SYS_COMP
  FROM CVERS
  WHERE COMPONENT = 'SAP_BASIS'.

SORT SYS_COMP BY RELEASE EXTRELEASE DESCENDING.
READ TABLE SYS_COMP INDEX 1.

CONCATENATE SYS_COMP-RELEASE '-' SYS_COMP-EXTRELEASE INTO SYS_BASIS.

MONI_RESULT-SYS_BASIS = SYS_BASIS.


*==================================================================

*### 1. AP 서비스 데이터 수집
*### 1-1. AP 서비스 전체 갯수
*### 1-2. AP 서비스 Active/Inactive

DATA: FT_AP_DATA LIKE TABLE OF MSXXLIST WITH HEADER LINE.

CLEAR: FT_AP_DATA. REFRESH: FT_AP_DATA.

CALL FUNCTION 'TH_SERVER_LIST'
  TABLES
    LIST = FT_AP_DATA.

CLEAR: TEMP_COUNT.

*### 1-1 데이터
MONI_RESULT-AP_COUNT = LINES( FT_AP_DATA ).

*### 1-2 데이터
LOOP AT FT_AP_DATA WHERE STATE = 1.
  TEMP_COUNT = TEMP_COUNT + 1.
ENDLOOP.

IF LINES( FT_AP_DATA ) > TEMP_COUNT.
  MONI_RESULT-AP_STATE = LINES( FT_AP_DATA ) - TEMP_COUNT.
ENDIF.

*==================================================================

*### 2. OS CPU, Memory, FileSystem 데이터 수집
*### 2-1. OS 사용률
*### 2-2. MEM 사용률
*### 2-3. FileSystem 사용량 여유량 / 오라클만 지원

DATA: FT_OS_CPU LIKE TABLE OF CPU_ALL     WITH HEADER LINE,
      FT_OS_MEM LIKE TABLE OF MEM_ALL     WITH HEADER LINE,
      FT_OS_FSY LIKE TABLE OF FSY_SINGLE  WITH HEADER LINE.

DATA: TEMP(10) TYPE N.

CLEAR: TEMP_COUNT.

*### 2-1. OS 사용률
CLEAR: FT_OS_CPU. REFRESH: FT_OS_CPU.

CALL FUNCTION 'GET_CPU_ALL'
  TABLES
    TF_CPU_ALL = FT_OS_CPU.

READ TABLE FT_OS_CPU INDEX 1.
MONI_RESULT-OS_CPU_USED = FT_OS_CPU-USR_TOTAL + FT_OS_CPU-SYS_TOTAL.
MONI_RESULT-OS_CPU_5AVG = FT_OS_CPU-LOAD5_AVG / 100.

*### 2-2. 메모리 사용률
CLEAR: FT_OS_MEM. REFRESH: FT_OS_MEM.

CALL FUNCTION 'GET_MEM_ALL'
  TABLES
    TF_MEM_ALL = FT_OS_MEM.

READ TABLE FT_OS_MEM INDEX 1.

CLEAR: TEMP.
TEMP = ( ( FT_OS_MEM-PHYS_MEM - FT_OS_MEM-FREE_MEM ) / FT_OS_MEM-PHYS_MEM ) * 100.
MONI_RESULT-OS_MEM_USED = TEMP.

CLEAR: TEMP.
TEMP = ( ( FT_OS_MEM-SWAP_SIZE - FT_OS_MEM-SWAP_FREE ) / FT_OS_MEM-SWAP_SIZE ) * 100.
MONI_RESULT-OS_MEM_SWAP = TEMP.


*### 2-3. 파일 시스템 사용률
CLEAR: FT_OS_FSY. REFRESH: FT_OS_FSY.

CALL FUNCTION 'GET_FSYS_SINGLE'
  TABLES
    TF_FSYS_SINGLE = FT_OS_FSY.

IF SY-DBSYS = 'ORACLE'.

  LOOP AT FT_OS_FSY WHERE FSYSNAME CP '/oracle/*'.
    TEMP_COUNT = ( FT_OS_FSY-FREE / FT_OS_FSY-CAPACITY ) * 100.

  ENDLOOP.

ENDIF.

*==================================================================

*### 3. DB 마지막 백업 성공 일자 수집
DATA: FT_DB_BACKUP   LIKE TABLE OF SDBAH    WITH HEADER LINE.
DATA: FT_HANA_BACKUP LIKE TABLE OF SDBADSDB WITH HEADER LINE .

IF SY-DBSYS = 'ORACLE'.

  CLEAR: FT_DB_BACKUP. REFRESH: FT_DB_BACKUP.

  SELECT BEG FUNCT OBJ RC INTO CORRESPONDING FIELDS OF TABLE FT_DB_BACKUP
    FROM SDBAH
    WHERE FUNCT = 'anf'
      AND RC = '0000'.

  SORT FT_DB_BACKUP BY BEG DESCENDING.

  READ TABLE FT_DB_BACKUP INDEX 1.

  MONI_RESULT-DB_BACKUP = FT_DB_BACKUP-BEG.

ELSEIF SY-DBSYS = 'HDB'.

  CLEAR: FT_HANA_BACKUP. REFRESH: FT_HANA_BACKUP.

  SELECT R3START BTYPE RC INTO CORRESPONDING FIELDS OF TABLE FT_HANA_BACKUP
    FROM SDBADSDB
    WHERE BTYPE = 'BCKUP'
      AND RC = '0000'.

  SORT FT_HANA_BACKUP BY R3START DESCENDING.

  READ TABLE FT_HANA_BACKUP INDEX 1.

  MONI_RESULT-DB_BACKUP = FT_HANA_BACKUP-R3START.

ENDIF.

*==================================================================

*### 4. DB 사용량/ 여유량 수집
*###   - Oracle 일 시, TableSpace PSAPSR3, PSAPSR3USR 확인
*###   - HANA 일 시, Memory, DISK 확인

DATA: HANA_MEMO_TOTAL(20) TYPE N,
      HANA_MEMO_USED(20)  TYPE N,
      HANA_DISK_TOTAL(20)  TYPE N,
      HANA_DISK_USED(20)  TYPE N.

*### Oracle
IF SY-DBSYS = 'ORACLE'.
  DATA: FT_DB_SPACE   LIKE TABLE OF TABLE_SPC    WITH HEADER LINE.

  CLEAR: FT_DB_SPACE. REFRESH: FT_DB_SPACE.

  CALL FUNCTION 'DB_ORA_CURRENT_SIZES'
    TABLES
      TS = FT_DB_SPACE.

  LOOP AT FT_DB_SPACE.

    IF FT_DB_SPACE-TS = 'PSAPSR3'.
      MONI_RESULT-DB_ORA_SR3_USED = FT_DB_SPACE-TPCTUSED.

    ELSEIF FT_DB_SPACE-TS = 'PSAPSR3USR'.
      MONI_RESULT-DB_ORA_USR_USED = FT_DB_SPACE-TPCTUSED.

    ENDIF.
  ENDLOOP.

*### HANA
ELSEIF SY-DBSYS = 'HDB'.
  DATA: FT_HANA_MEMO  TYPE TABLE OF HDB_M_MEMORY WITH HEADER LINE,
        FT_HANA_DISK  TYPE TABLE OF HDB_M_DISKS  WITH HEADER LINE.

  DATA: HANA_INDEXS_PORT(5) TYPE N.

*### HANA MEMEORY
  CLEAR: HANA_MEMO_TOTAL, HANA_MEMO_USED.

*### HANA DB indexserver 내부 포트 확인
  EXEC SQL.
    SELECT
      PORT
    FROM
      M_SERVICES
    WHERE
      SERVICE_NAME = 'indexserver'
    INTO
      :HANA_INDEXS_PORT
  ENDEXEC.

  EXEC SQL.
    SELECT
      VALUE
    FROM
      M_MEMORY
    WHERE
      NAME = 'GLOBAL_ALLOCATION_LIMIT' AND
      PORT = :HANA_INDEXS_PORT
    INTO
      :FT_HANA_MEMO-MEMORY_VALUE
  ENDEXEC.

  HANA_MEMO_TOTAL = FT_HANA_MEMO-MEMORY_VALUE.

  EXEC SQL.
    SELECT
      VALUE
    FROM
      M_MEMORY
    WHERE
      NAME = 'TOTAL_MEMORY_SIZE_IN_USE' AND
      PORT = :HANA_INDEXS_PORT
    INTO
      :FT_HANA_MEMO-MEMORY_VALUE
  ENDEXEC.

  HANA_MEMO_USED = FT_HANA_MEMO-MEMORY_VALUE.

  MONI_RESULT-DB_HDB_MEM_USED = ( HANA_MEMO_USED / HANA_MEMO_TOTAL ) * 100.

*### HANA DISK
  CLEAR: HANA_DISK_TOTAL, HANA_DISK_USED.

  EXEC SQL.
    SELECT
      TOTAL_SIZE,
      USED_SIZE
    FROM
      M_DISKS
    WHERE PATH LIKE '/hana/data/%'
    INTO
      :FT_HANA_DISK-VOLUME_SIZE,
      :FT_HANA_DISK-DATA_SIZE
  ENDEXEC.

  HANA_DISK_TOTAL = FT_HANA_DISK-VOLUME_SIZE.
  HANA_DISK_USED  = FT_HANA_DISK-DATA_SIZE.

  MONI_RESULT-DB_HDB_DIS_USED = ( FT_HANA_DISK-DATA_SIZE / FT_HANA_DISK-VOLUME_SIZE ) * 100.


ENDIF.

*==================================================================

*### 5. DBA 작업 확인
DATA: FT_DB_DBA   LIKE TABLE OF SDBAH    WITH HEADER LINE.
DATA: FT_HANA_DBA LIKE TABLE OF SDBADSDB WITH HEADER LINE .


CLEAR: TEMP_DATE1, TEMP_DATE2, START_DATE, END_DATE.

TEMP_DATE1 = SY-DATUM.
TEMP_DATE2 = SY-DATUM - 1.

CONCATENATE TEMP_DATE1 SY-UZEIT+0(2) '%' INTO END_DATE.
CONCATENATE TEMP_DATE2 SY-UZEIT+0(2) '%' INTO START_DATE.

IF SY-DBSYS = 'ORACLE'.

  CLEAR: FT_DB_DBA. REFRESH: FT_DB_DBA.

  SELECT BEG FUNCT OBJ RC INTO CORRESPONDING FIELDS OF TABLE FT_DB_DBA
    FROM SDBAH
    WHERE ( RC <> '0000' and RC <> '0001' )
      AND BEG >= START_DATE
      AND BEG < END_DATE.

  MONI_RESULT-DB_DBA_ERROR = LINES( FT_DB_DBA ).

ELSEIF SY-DBSYS = 'HDB'.

  CLEAR: FT_HANA_DBA. REFRESH: FT_HANA_DBA.

  SELECT R3START BTYPE RC INTO CORRESPONDING FIELDS OF TABLE FT_HANA_DBA
    FROM SDBADSDB
    WHERE ( RC <> '0000' and RC <> '0001' )
      AND R3START >= START_DATE
      AND R3START < END_DATE.

  MONI_RESULT-DB_DBA_ERROR = LINES( FT_HANA_DBA ).

ENDIF.

*==================================================================

*### 6. DB LOCK 확인
DATA: DB_LOCK_COUNT(5) TYPE N.

IF SY-DBSYS = 'ORACLE'.

  CLEAR: DB_LOCK_COUNT.

  EXEC SQL.
    SELECT
      BLOCK
    FROM
      V$LOCK
    WHERE BLOCK > 0
    INTO
      :DB_LOCK_COUNT
  ENDEXEC.

  MONI_RESULT-DB_LOCK_ERROR = DB_LOCK_COUNT.

ELSEIF SY-DBSYS = 'HDB'.
  DATA: DB_HANA_BLOCK TYPE TABLE OF HDB_M_BLOCKED_TRANSACTIONS WITH HEADER LINE.

  CLEAR: DB_HANA_BLOCK. REFRESH: DB_HANA_BLOCK.

  EXEC SQL.
    SELECT
      BLOCKED_TIME
    FROM
      M_BLOCKED_TRANSACTIONS
    INTO
      :DB_HANA_BLOCK-BLOCKED_TIME
  ENDEXEC.

  MONI_RESULT-DB_LOCK_ERROR = LINES( DB_HANA_BLOCK ).


ENDIF.

*==================================================================

*### 7. DB Alert
DATA: LV_CHECK(4) TYPE C.
DATA: ALERT_COUNT(5) TYPE N.

DATA : BEGIN OF TEMP_ALERT OCCURS 0,
         COUNT(10) TYPE N,
       END OF TEMP_ALERT.

IF SY-DBSYS = 'ORACLE'.

  CLEAR: ALERT_COUNT.

  "### 오라클의 경우, Alert 를 확인하기 위해서 SAPSR3 에 V$DIAG_ALERT_EXT 조회 권한을 부여해줘야 한다.
  "### GRANT SELECT ON V$DIAG_ALERT_EXT TO SAPSR3;
  "### 권한이 없다면, -1 INACTIVE 값을 띄우도록 설정
  TRY.
    EXEC SQL.
      SELECT
        COUNT(*)
      FROM
        V$DIAG_ALERT_EXT
      WHERE
        ORIGINATING_TIMESTAMP > ( SYSDATE - 1 ) AND
        MESSAGE_TEXT LIKE '%ORA-%' OR
        MESSAGE_TEXT LIKE '%Fatal%' OR
        MESSAGE_TEXT LIKE '%ERROR%' OR
        MESSAGE_TEXT LIKE '%CRITICAL%'
      INTO
        :ALERT_COUNT
    ENDEXEC.
  CATCH CX_SY_NATIVE_SQL_ERROR.
    MONI_RESULT-DB_ALERT_COUNT = -1.

  ENDTRY.

  MONI_RESULT-DB_ALERT_COUNT = ALERT_COUNT.


ELSEIF SY-DBSYS = 'HDB'.
  DATA: DB_HANA_TENANT TYPE TABLE OF HDB_M_TENANTS WITH HEADER LINE.

  CLEAR: LV_CHECK, TEMP_ALERT, DB_HANA_TENANT, ALERT_COUNT. REFRESH: TEMP_ALERT, DB_HANA_TENANT.

  EXEC SQL.
    SELECT
      VALUE
    FROM
      M_SYSTEM_OVERVIEW
    WHERE
      NAME = 'Alerts'
    INTO
      :DB_HANA_TENANT-ALERTS
  ENDEXEC.

  TEMP_ALERT = DB_HANA_TENANT-ALERTS.

  SPLIT DB_HANA_TENANT-ALERTS AT SPACE INTO TABLE TEMP_ALERT.

  LOOP AT TEMP_ALERT.
    CALL FUNCTION 'NUMERIC_CHECK'
      EXPORTING
        STRING_IN = TEMP_ALERT-COUNT
      IMPORTING
        HTYPE = LV_CHECK.

    IF LV_CHECK = 'NUMC'.
      ALERT_COUNT = ALERT_COUNT + TEMP_ALERT-COUNT.
    ENDIF.

  ENDLOOP.

  MONI_RESULT-DB_ALERT_COUNT = ALERT_COUNT.

ENDIF.

*==================================================================

*### 8. 배치잡 오류 수집
DATA: ABAP_BATCH_CNT(5) TYPE N.

CLEAR: TEMP_DATE1, TEMP_DATE2, START_DATE, END_DATE.

TEMP_DATE1 = SY-DATUM.
TEMP_DATE2 = SY-DATUM - 1.

CLEAR: ABAP_BATCH_CNT.

SELECT COUNT(*) INTO ABAP_BATCH_CNT
  FROM TBTCO
  WHERE STATUS = 'A'
    AND ( ( ENDDATE > TEMP_DATE2  AND ENDDATE <  TEMP_DATE1 ) OR
          ( ( ENDDATE = TEMP_DATE2 AND ENDTIME >= SY-UZEIT ) OR
            ( ENDDATE = TEMP_DATE1 AND ENDTIME <= SY-UZEIT ) ) ).

MONI_RESULT-ABAP_BTC_AERR = ABAP_BATCH_CNT.

CLEAR: ABAP_BATCH_CNT.

SELECT COUNT(*) INTO ABAP_BATCH_CNT
  FROM TBTCO
  WHERE JOBNAME NOT LIKE 'Z%'
    AND STATUS = 'A'
    AND ( ( ENDDATE > TEMP_DATE2  AND ENDDATE <  TEMP_DATE1 ) OR
          ( ( ENDDATE = TEMP_DATE2 AND ENDTIME >= SY-UZEIT ) OR
            ( ENDDATE = TEMP_DATE1 AND ENDTIME <= SY-UZEIT ) ) ).

MONI_RESULT-ABAP_BTC_SERR = ABAP_BATCH_CNT.

CLEAR: ABAP_BATCH_CNT.

SELECT COUNT(*) INTO ABAP_BATCH_CNT
  FROM TBTCO
  WHERE JOBNAME LIKE 'Z%'
    AND STATUS = 'A'
    AND ( ( ENDDATE > TEMP_DATE2  AND ENDDATE <  TEMP_DATE1 ) OR
          ( ( ENDDATE = TEMP_DATE2 AND ENDTIME >= SY-UZEIT ) OR
            ( ENDDATE = TEMP_DATE1 AND ENDTIME <= SY-UZEIT ) ) ).

MONI_RESULT-ABAP_BTC_ZERR = ABAP_BATCH_CNT.

*==================================================================

*### 9. ABAP DUMP 확인

DATA: ABAP_DUMP_CNT(5) TYPE N.

CLEAR: TEMP_DATE1, TEMP_DATE2, START_DATE, END_DATE.

TEMP_DATE1 = SY-DATUM.
TEMP_DATE2 = SY-DATUM - 1.

SELECT COUNT(*) INTO ABAP_DUMP_CNT
  FROM SNAP
  WHERE SEQNO = '000'
    AND ( ( DATUM > TEMP_DATE2  AND DATUM <  TEMP_DATE1 ) OR
          ( ( DATUM = TEMP_DATE2 AND UZEIT >= SY-UZEIT ) OR
            ( DATUM = TEMP_DATE1 AND UZEIT <= SY-UZEIT ) ) ).

MONI_RESULT-ABAP_DUMP_COUNT = ABAP_DUMP_CNT.

*==================================================================

*### 10. 시스템 로그 확인





*==================================================================

*### 11. ABAP LOCK 확인 (Old Lock)

DATA:ABAP_LOCK LIKE TABLE OF SEQG3 WITH HEADER LINE.

CALL FUNCTION 'ENQUE_READ'
  EXPORTING
    GCLIENT = ''
    GUNAME = ''
  TABLES
    ENQ = ABAP_LOCK.

LOOP AT ABAP_LOCK WHERE GTDATE < SY-DATUM AND GNAME <> 'FDC_TIMERDAEMON_LOCK'.
  MONI_RESULT-ABAP_ENQ_LOCK = MONI_RESULT-ABAP_ENQ_LOCK + 1.
ENDLOOP.

*==================================================================

*### 12. 작업 프로세스 확인

DATA: ABAP_WP LIKE TABLE OF WPINFOS WITH HEADER LINE.

CALL FUNCTION 'TH_SYSTEMWIDE_WPINFO'
  TABLES
    WPLIST = ABAP_WP.

LOOP AT ABAP_WP.

  *### DIA 작업 중, 3시간 이상(10800s) 수행 중인 WP 는 오류로 인식 (하드코딩)
  IF ABAP_WP-WP_TYP = 'DIA'.
    IF ABAP_WP-WP_ELTIME > 10800.
      MONI_RESULT-ABAP_WP_DIA = MONI_RESULT-ABAP_WP_DIA + 1.
    ENDIF.

  *### BGD 작업 중, 12시간 이상(43200s) 수행 중인 WP 는 오류로 인식 (하드코딩)
  ELSEIF ABAP_WP-WP_TYP = 'BGD'.
    IF ABAP_WP-WP_ELTIME > 43200.
      MONI_RESULT-ABAP_WP_BGD = MONI_RESULT-ABAP_WP_BGD + 1.
    ENDIF.

  ENDIF.
ENDLOOP.

*==================================================================

*### 13. 업데이트 시스템 및 요청 확인

DATA: TH_OPCODE(1) TYPE X,
      VB_GET_INFO  LIKE TH_OPCODE VALUE 17.
DATA: VBINFO TYPE TABLE OF VBINFO WITH HEADER LINE.
DATA: ABAP_UPDERR_CNT(5) TYPE N.

CALL 'ThVBCall'
  ID 'OPCODE' FIELD VB_GET_INFO
  ID 'VBINFO' FIELD VBINFO.

IF SY-SUBRC = 0.

  IF VBINFO-VB_ACTIVE = 1.
*    VBSINFO = 'OK'.
    MONI_RESULT-ABAP_UPD_STATE = ''.

  ELSE.
    IF VBINFO-AUTOSTOP = 1.
*      VBSINFO = 'Deactivated by system'.
      MONI_RESULT-ABAP_UPD_STATE = 'X'.
    ELSE.
*      VBSINFO = 'Deactivated by user'.
      MONI_RESULT-ABAP_UPD_STATE = 'X'.
    ENDIF.
  ENDIF.

ENDIF.


CLEAR: TEMP_DATE1, TEMP_DATE2, START_DATE, END_DATE.

TEMP_DATE1 = SY-DATUM.
TEMP_DATE2 = SY-DATUM - 1.

CONCATENATE TEMP_DATE1 SY-UZEIT+0(2) '%' INTO END_DATE.
CONCATENATE TEMP_DATE2 SY-UZEIT+0(2) '%' INTO START_DATE.

SELECT COUNT(*) INTO ABAP_UPDERR_CNT
  FROM VBHDR
  WHERE VBRC = '9'
    AND VBDATE >= START_DATE
    AND VBDATE < END_DATE.

MONI_RESULT-ABAP_UPD_ERR = ABAP_UPDERR_CNT.

*==================================================================

*### 14. 스풀 사용량 확인

DATA: ABAP_SPOOL_MAX(10) TYPE N,
      ABAP_SPOOL_MIN(10) TYPE N,
      ABAP_SPOOL_CUR(10) TYPE N.

EXEC SQL.
  SELECT
    FROMNUMBER,
    TONUMBER
  FROM
    NRIV
  WHERE
    CLIENT = '000' AND
    OBJECT = 'SPO_NUM'
  INTO
    :ABAP_SPOOL_MIN,
    :ABAP_SPOOL_MAX
ENDEXEC.

SELECT COUNT(*) INTO ABAP_SPOOL_CUR
  FROM TSP01.

MONI_RESULT-ABAP_SPOOL_PER = ( ABAP_SPOOL_CUR / ( ABAP_SPOOL_MAX - ABAP_SPOOL_MIN ) ) * 100.


*==================================================================

*### 15. 사용자 세션  확인

DATA: ABAP_SESSIONS LIKE TABLE OF UINFOS WITH HEADER LINE.
DATA: TEMP_TIME2 TYPE T.

CLEAR: TEMP_TIME.

TEMP_TIME = SY-UZEIT + 120.

CALL FUNCTION 'TH_SYSTEMWIDE_USER_LIST'
  TABLES
    LIST = ABAP_SESSIONS.

LOOP AT ABAP_SESSIONS.

  CONCATENATE ABAP_SESSIONS-ZEIT+0(2) ABAP_SESSIONS-ZEIT+3(2) ABAP_SESSIONS-ZEIT+6(2) INTO TEMP_TIME2.

  IF TEMP_TIME2 > TEMP_TIME.

    MONI_RESULT-ABAP_DEAD_SESS = MONI_RESULT-ABAP_DEAD_SESS + 1.

  ENDIF.

ENDLOOP.

*==================================================================

*### 16. SAP Memory, Buffer 확인

DATA: ABAP_BUFFER LIKE TABLE OF TUNEHDWQ   WITH HEADER LINE,
      ABAP_ROLL   LIKE TABLE OF RLPG_STAT  WITH HEADER LINE,
      ABAP_PAGE   LIKE TABLE OF RLPG_STAT  WITH HEADER LINE,
      ABAP_EXTM   LIKE TABLE OF EMSTATUSAG WITH HEADER LINE,
      ABAP_EXTG   LIKE TABLE OF EXGLOBMEMS WITH HEADER LINE,
      ABAP_SHRO   LIKE TABLE OF SHROBJMEMS WITH HEADER LINE,
      ABAP_HEAP   LIKE TABLE OF HPSTATUSAG WITH HEADER LINE.

DATA: TEMP_MEM(10) TYPE N.

CALL FUNCTION 'SAPTUNE_GET_SUMMARY_STATISTIC'
  IMPORTING
    ROLL_AREA             = ABAP_ROLL
    PAGING_AREA           = ABAP_PAGE
    EXTENDED_MEMORY_USAGE = ABAP_EXTM
    EX_GLOB_MEM_USAGE     = ABAP_EXTG
    SHR_OBJ_MEM_USAGE     = ABAP_SHRO
    HEAP_MEMORY_USAGE     = ABAP_HEAP
  TABLES
    BUFFER_STATISTIC = ABAP_BUFFER.

*### 16-1. Buffer Swap 확인
*### SWAP 을 사용해도, Hit Rate 가 95% 이상이라면 문제 없음으로 인식.
LOOP AT ABAP_BUFFER WHERE SWAP > 0.

  IF ABAP_BUFFER-HITRATIO < 95.

    MONI_RESULT-ABAP_BUF_SWAP = MONI_RESULT-ABAP_BUF_SWAP + 1.

  ENDIF.

ENDLOOP.

*### 16-2. SAP Memory TOTAL 대비 MaxUse 퍼센트 확인
IF ABAP_ROLL-MAX_USED = 0.
  MONI_RESULT-ABAP_MEM_ROLL = 0.
ELSE.
  CLEAR: TEMP_MEM.
  TEMP_MEM = ( ABAP_ROLL-MAX_USED / ( ABAP_ROLL-FILE_SIZE + ABAP_ROLL-AREA_SHM ) ) * 100.
  MONI_RESULT-ABAP_MEM_ROLL = TEMP_MEM.
ENDIF.

IF ABAP_PAGE-MAX_USED = 0.
  MONI_RESULT-ABAP_MEM_PAGE = 0.
ELSE.
  CLEAR: TEMP_MEM.
  TEMP_MEM = ( ABAP_PAGE-MAX_USED / ( ABAP_PAGE-FILE_SIZE + ABAP_PAGE-AREA_SHM ) ) * 100.
  MONI_RESULT-ABAP_MEM_PAGE = TEMP_MEM.
ENDIF.

IF ABAP_EXTM-USED = 0.
  MONI_RESULT-ABAP_MEM_EXTM = 0.
ELSE.
  CLEAR: TEMP_MEM.
  TEMP_MEM = ( ABAP_EXTM-USED / ABAP_EXTM-TOTAL ) * 100.
  MONI_RESULT-ABAP_MEM_EXTM = TEMP_MEM.
ENDIF.

IF ABAP_EXTG-PEAK = 0.
  MONI_RESULT-ABAP_MEM_EXTG = 0.
ELSE.
  CLEAR: TEMP_MEM.
  TEMP_MEM = ( ABAP_EXTG-PEAK / ABAP_EXTG-TOTAL ) * 100.
  MONI_RESULT-ABAP_MEM_EXTG = TEMP_MEM.
ENDIF.

IF ABAP_SHRO-ALLOC = 0.
  MONI_RESULT-ABAP_MEM_SHRO = 0.
ELSE.
  CLEAR: TEMP_MEM.
  TEMP_MEM = ( ABAP_SHRO-ALLOC / ( ABAP_SHRO-ALLOC + ABAP_SHRO-FREE ) ) * 100.
  MONI_RESULT-ABAP_MEM_SHRO = TEMP_MEM.
ENDIF.

IF ABAP_HEAP-USED = 0.
  MONI_RESULT-ABAP_MEM_HEAP = 0.
ELSE.
  CLEAR: TEMP_MEM.
  TEMP_MEM = ( ABAP_HEAP-USED / ABAP_HEAP-TOTAL ) * 100.
  MONI_RESULT-ABAP_MEM_HEAP = TEMP_MEM.
ENDIF.

*==================================================================

*### 17. RFC Queue 확인

DATA: ABAP_RFC_ERR(10) TYPE N.

CLEAR: ABAP_RFC_ERR.

*### 17-1. tRFC SYSFAIL 확인
SELECT COUNT(*) INTO ABAP_RFC_ERR
  FROM ARFCSSTATE
  WHERE ARFCSTATE  = 'SYSFAIL'
    AND ARFCRETURN = ''.

MONI_RESULT-ABAP_TRFC_ERR = ABAP_RFC_ERR.

CLEAR: ABAP_RFC_ERR.

*### 17-2. qRFC Outbound SYSFAIL 확인
SELECT COUNT(*) INTO ABAP_RFC_ERR
  FROM TRFCQOUT
  WHERE QSTATE = 'SYSFAIL'.

MONI_RESULT-ABAP_QRFC_OERR = ABAP_RFC_ERR.

CLEAR: ABAP_RFC_ERR.

*### 17-3. qRFC Inbound SYSFAIL 확인
SELECT COUNT(*) INTO ABAP_RFC_ERR
  FROM TRFCQIN
  WHERE QSTATE = 'SYSFAIL'.

MONI_RESULT-ABAP_QRFC_IERR = ABAP_RFC_ERR.

*==================================================================

APPEND MONI_RESULT.


ENDFUNCTION.

 


3. GUI Status

GUI Status Name : S100

Application Toolbar

  • REPORT
    -> Function Text : REPORT
    -> Icon Name : ICON_HISTORY
    -> Icon Text / Info. Text : Report
  • ADD_PROF
    -> Function Text : ADD_PROF
    -> Icon Name : ICON_INSERT_MULTIPLE_LINES
    -> Icon Text / Info. Text : Add Profile

 


4. ABAP Dictionary

4-1. ZBC_MONI_DATA (메인 시스템에만 생성)

필드 전부 BuiltIn Type

FieldKeyInitVDTypeLenDesc

REPORT_DATE X X DATS 8 REPORT Create Date
REPORT_TIME X X TIMS 6 REPORT Create Time
REPORT_USER X X CHAR 12 REPORT Create User
SYS_SID X X CHAR 3 SYSTEM SID
SYS_OS     CHAR 20 SYSTEM OS Type
SYS_DB     CHAR 20 SYSTEM DB Type
SYS_HOSTNAME     CHAR 20 SYSTEM HOSTNAME
SYS_KERNEL     CHAR 20 SYSTEM SAP Kernel Version
SYS_BASIS     CHAR 20 SYSTEM SAP-BASIS Version
AP_COUNT     NUMC 2 AP Service TOTAL Count
AP_STATE     NUMC 2 AP Service Inactive Count
OS_CPU_USED     INT2 5 OS TOTAL CPU Avg. Usage
OS_CPU_5AVG     INT2 5 OS TOTAL CPU 5min AVG. Load
OS_MEM_USED     INT2 5 OS Memory Usage (%)
OS_MEM_SWAP     INT2 5 OS Memory SWAP Usage (%)
OS_FSY_STATE     CHAR 1 OS FileSystem State (FAIL=X)
DB_BACKUP     CHAR 14 DB Last Successful Backup date
DB_ORA_SR3_USED     INT2 5 DB Oracle PSAPSR3 Usage (%)
DB_ORA_USR_USED     INT2 5 DB Oracle PSAPSR3USR Usage (%)
DB_HDB_MEM_USED     INT2 5 DB HANA Memory Usage (%)
DB_HDB_DIS_USED     INT2 5 DB HANA Disk Usage (%)
DB_DBA_ERROR     INT2 5 DBA JOB Error Count
DB_LOCK_ERROR     INT2 5 DB LOCK Count
DB_ALERT_COUNT     INT2 5 DB Alert Count
ABAP_BTC_AERR     INT2 5 ABAP All Batch Job Error Count
ABAP_BTC_SERR     INT2 5 ABAP Standard Batch Job Error Count
ABAP_BTC_ZERR     INT2 5 ABAP ZCBO Batch Job Error Count
ABAP_DUMP_COUNT     INT2 5 ABAP DUMP Count
ABAP_ENQ_LOCK     INT2 5 ABAP ENQ LOCK Count
ABAP_WP_DIA     INT2 5 ABAP DIA Over-Running WP Count (3h)
ABAP_WP_BGD     INT2 5 ABAP BGD Over-Running WP Count (12h)
ABAP_UPD_STATE     CHAR 1 ABAP UPDATE System State (FAIL=X)
ABAP_UPD_ERR     INT2 5 ABAP UPDATE Request Error Count
ABAP_SPOOL_PER     INT2 5 ABAP SPOOL Usage (%)
ABAP_DEAD_SESS     INT2 5 ABAP Dead Session Count
ABAP_BUF_SWAP     INT2 5 ABAP Swap Used Buffer Count
ABAP_MEM_ROLL     INT2 5 ABAP ROLL Memory MaxUsage (%)
ABAP_MEM_PAGE     INT2 5 ABAP PAGE Memory MaxUsage (%)
ABAP_MEM_EXTM     INT2 5 ABAP Extended Memory MaxUsage (%)
ABAP_MEM_EXTG     INT2 5 ABAP Ext. Global Memory MaxUsage (%)
ABAP_MEM_SHRO     INT2 5 ABAP Shared Objects Memory MaxUsage (%)
ABAP_MEM_HEAP     INT2 5 ABAP Heap Memory MaxUsage (%)
ABAP_TRFC_ERR     INT4 10 ABAP tRFC SYSFAIL Count
ABAP_QRFC_OERR     INT4 10 ABAP qRFC Outbound SYSFAIL Count
ABAP_QRFC_IERR     INT4 10 ABAP qRFC Inbound SYSFAIL Count

 

4-2. ZBC_MONI_PROFILE (메인 시스템에만 생성)

필드 전부 BuiltIn Type

FieldKeyInitVDTypeLenDesc

SID X X DATS 3 System SID
TYPE X X TIMS 1 Alert Type (1=Warning, 2=Critical)
OBJECT X X CHAR 20 Object Name (ZBC_MONI_COLLECT_DATA Field)
THRESHOLD     INT2 5 Threshold Vaule

 

4-3. ZBC_MONI_COLLECT_DATA (메인 시스템, RFC 시스템 생성)

Structure, 필드 전부 BuiltIn Type

ComponentTyping MDtypeLenDesc

SYS_SID Types CHAR 3 SYSTEM SID
SYS_OS Types CHAR 20 SYSTEM OS Type
SYS_DB Types CHAR 20 SYSTEM DB Type
SYS_HOSTNAME Types CHAR 20 SYSTEM HOSTNAME
SYS_KERNEL Types CHAR 20 SYSTEM SAP Kernel Version
SYS_BASIS Types CHAR 20 SYSTEM SAP-BASIS Version
AP_COUNT Types NUMC 2 AP Service TOTAL Count
AP_STATE Types NUMC 2 AP Service Inactive Count
OS_CPU_USED Types INT2 5 OS TOTAL CPU Avg. Usage
OS_CPU_5AVG Types INT2 5 OS TOTAL CPU 5min AVG. Load
OS_MEM_USED Types INT2 5 OS Memory Usage (%)
OS_MEM_SWAP Types INT2 5 OS Memory SWAP Usage (%)
OS_FSY_STATE Types CHAR 1 OS FileSystem State (FAIL=X)
DB_BACKUP Types CHAR 14 DB Last Successful Backup TimeStamp
DB_ORA_SR3_USED Types INT2 5 DB Oracle PSAPSR3 Usage (%)
DB_ORA_USR_USED Types INT2 5 DB Oracle PSAPSR3USR Usage (%)
DB_HDB_MEM_USED Types INT2 5 DB HANA Memory Usage (%)
DB_HDB_DIS_USED Types INT2 5 DB HANA Disk Usage (%)
DB_DBA_ERROR Types INT2 5 DBA JOB Error Count
DB_LOCK_ERROR Types INT2 5 DB LOCK Count
DB_ALERT_COUNT Types INT2 5 DB Alert Count
ABAP_BTC_AERR Types INT2 5 ABAP All Batch Job Error Count
ABAP_BTC_SERR Types INT2 5 ABAP Standard Batch Job Error Count
ABAP_BTC_ZERR Types INT2 5 ABAP ZCBO Batch Job Error Count
ABAP_DUMP_COUNT Types INT2 5 ABAP DUMP Count
ABAP_ENQ_LOCK Types INT2 5 ABAP ENQ Old LOCK Count
ABAP_WP_DIA Types INT2 5 ABAP DIA Over-Running WP Count (3h)
ABAP_WP_BGD Types INT2 5 ABAP BGD Over-Running WP Count (12h)
ABAP_UPD_STATE Types CHAR 1 ABAP UPDATE System State (FAIL=X)
ABAP_UPD_ERR Types INT2 5 ABAP UPDATE Request Error Count
ABAP_SPOOL_PER Types INT2 5 ABAP SPOOL Usage (%)
ABAP_DEAD_SESS Types INT2 5 ABAP Dead Session Count
ABAP_BUF_SWAP Types INT2 5 ABAP Swap Used Buffer Count
ABAP_MEM_ROLL Types INT2 5 ABAP ROLL Memory MaxUsage (%)
ABAP_MEM_PAGE Types INT2 5 ABAP PAGE Memory MaxUsage (%)
ABAP_MEM_EXTM Types INT2 5 ABAP Extended Memory MaxUsage (%)
ABAP_MEM_EXTG Types INT2 5 ABAP Ext. Global Memory MaxUsage (%)
ABAP_MEM_SHRO Types INT2 5 ABAP Shared Objects Memory MaxUsage (%)
ABAP_MEM_HEAP Types INT2 5 ABAP Heap Memory MaxUsage (%)
ABAP_TRFC_ERR Types INT4 10 ABAP tRFC SYSFAIL Count
ABAP_QRFC_OERR Types INT4 10 ABAP qRFC Outbound SYSFAIL Count
ABAP_QRFC_IERR Types INT4 10 ABAP qRFC Inbound SYSFAIL Count