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

User load and dialog step number for a selected day



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



Joined: 01 Sep 2007
Posts: 1636

PostPosted: Sun Nov 25, 2007 12:53 pm    Post subject: User load and dialog step number for a selected day Reply with quote

Create a graphical chart of user load and dialog step number for a selected day

Code:

*
*  This program creates a graphical user load and dialog step chart
*  for a specific day.
*
*
REPORT ZUSRLOAD NO STANDARD PAGE HEADING.

PARAMETERS: DATE LIKE AMDS-ANDAT DEFAULT SY-DATUM.

DATA: M(3), CLIN(7) TYPE N, CCLIN(7), DATEC(25), MAX TYPE I,
MONTH(36) VALUE 'JanFebMarAprMayJunJulAugSepOctNovDec',
MONTHNUM(2) TYPE N, DAYNUM(2) TYPE N, ITIM(4), LIN TYPE I,
IDAT(8), A(50), FILE(30) VALUE '/usr/sap/trans/usr_login_log',
LINC(7), X1 TYPE F VALUE 6, X2 TYPE F VALUE 20, Y1 TYPE F VALUE 0,
Y2 TYPE F VALUE 320.

DATA: BEGIN OF ITAB OCCURS 500,
 TIME(4), DB TYPE I, AP1 TYPE I, AP2 TYPE I, AP3 TYPE I, SUM TYPE I,
 DS1 TYPE I, DS2 TYPE I,
END OF ITAB.
DATA: BEGIN OF OPTS OCCURS 1,
 C(80),
END OF OPTS.
DATA: BEGIN OF DATA OCCURS 1,
 W TYPE F,
 F TYPE F,
END OF DATA.
DATA: BEGIN OF TASKTYPE_RES OCCURS 30,
 TIME TYPE F, SUM1 TYPE F, SUM2 TYPE F,
END OF TASKTYPE_RES.
DATA: BEGIN OF TASKTYPE_STATISTIC OCCURS 50.
 INCLUDE STRUCTURE  SAPWLTSKTI.
DATA: END OF TASKTYPE_STATISTIC.
DATA: PERIODTYPE LIKE  SAPWLACCTP-PERIODTYPE VALUE 'D',
 HOSTID     LIKE  SAPWLACCTP-HOSTID.
DATA: BEGIN OF TASKTYPE_SUM OCCURS 50,
 TIME LIKE SAPWLTSKTI-TIME,
 COUNT LIKE SAPWLTSKTI-COUNT,
 CSUM LIKE SAPWLTSKTI-COUNT,
 CNT001 LIKE SAPWLRTDIS-CNT001,
 CNT002 LIKE SAPWLRTDIS-CNT001,
 CNT003 LIKE SAPWLRTDIS-CNT001,
 CNT004 LIKE SAPWLRTDIS-CNT001,
 CNT005 LIKE SAPWLRTDIS-CNT001,
 CNT006 LIKE SAPWLRTDIS-CNT001,
 CNT007 LIKE SAPWLRTDIS-CNT001,
 CNT008 LIKE SAPWLRTDIS-CNT001,
 CNT009 LIKE SAPWLRTDIS-CNT001,
END OF TASKTYPE_SUM.

HOSTID = 'aaaaaaaa'. PERFORM CALCULATE.
HOSTID = 'ssssssss'. PERFORM CALCULATE.
HOSTID = 'dddddddd'. PERFORM CALCULATE.
HOSTID = 'ffffffff'. PERFORM CALCULATE.
LOOP AT TASKTYPE_SUM.
  IF TASKTYPE_SUM-TIME CS '00--06' OR
     TASKTYPE_SUM-TIME CS '21--24' OR
     TASKTYPE_SUM-TIME CS '20--21'.
     DELETE TASKTYPE_SUM.
  ENDIF.
ENDLOOP.

LOOP AT TASKTYPE_SUM.
  SHIFT TASKTYPE_SUM-TIME RIGHT BY 3 PLACES.
  TASKTYPE_SUM-TIME+5(2) = '30'.
  TASKTYPE_RES-TIME = TASKTYPE_SUM-TIME.
  TASKTYPE_RES-SUM1 = TASKTYPE_SUM-CNT001 + TASKTYPE_SUM-CNT002 +
  TASKTYPE_SUM-CNT003 + TASKTYPE_SUM-CNT004 +
  TASKTYPE_SUM-CNT005 + TASKTYPE_SUM-CNT006.
  TASKTYPE_RES-SUM2 = TASKTYPE_SUM-COUNT.
  APPEND TASKTYPE_RES.
ENDLOOP.

MAX = 0.
LOOP AT TASKTYPE_RES.
  IF TASKTYPE_RES-SUM2 > MAX.
    MAX = TASKTYPE_RES-SUM2.
  ENDIF.
ENDLOOP.

LOOP AT TASKTYPE_RES.
 TASKTYPE_RES-SUM1 = TASKTYPE_RES-SUM1 * ( 250 / MAX ).
 TASKTYPE_RES-SUM2 = TASKTYPE_RES-SUM2 * ( 250 / MAX ).
 TASKTYPE_RES-TIME = TASKTYPE_RES-TIME / 100.
 MODIFY TASKTYPE_RES.
ENDLOOP.

READ DATASET FILE INTO A.
OPEN DATASET FILE FOR INPUT IN TEXT MODE.
DO.
  IF A+0(1) <> 'p'.
    M = A+4(3).
    SEARCH MONTH FOR M.
    MONTHNUM = ( SY-FDPOS / 3 ) + 1.
    DAYNUM = A+8(2).
    IDAT = A+24(4). IDAT+4(2) = MONTHNUM. IDAT+6(2) = DAYNUM.
    ITIM = A+11(2). ITIM+2(2) = A+14(2).
    IF IDAT = DATE.
      ITAB-DB = ITAB-AP1 = ITAB-AP2 = ITAB-AP3 = 0.
      DO.
        READ DATASET FILE INTO A.
        IF A+0(1) = 'p'.
        ELSE.
          EXIT.
        ENDIF.
        IF SY-SUBRC <> 0 .EXIT. ENDIF.
        CASE A(8).
          WHEN 'aaaaaaaa'.
            ITAB-DB = A+25(10).
          WHEN 'ssssssss'.
            ITAB-AP1 = A+25(10).
          WHEN 'dddddddd'.
            ITAB-AP2 = A+25(10).
          WHEN 'ffffffff'.
            ITAB-AP3 = A+25(10).
        ENDCASE.
      ENDDO.
      ITAB-TIME = ITIM / 100.
      APPEND ITAB.
    ENDIF.
  ENDIF.
  READ DATASET FILE INTO A.
  IF SY-SUBRC <> 0 .EXIT. ENDIF.
ENDDO.

LOOP AT ITAB.
  ITAB-SUM = ITAB-DB + ITAB-AP1 + ITAB-AP2 + ITAB-AP3.
  MODIFY ITAB.
ENDLOOP.

LOOP AT ITAB.
  DATA-W = ITAB-TIME.
  DATA-F = ITAB-SUM.
  APPEND DATA.
ENDLOOP.
LOOP AT ITAB.
  DATA-W = ITAB-TIME.
  DATA-F = ITAB-DB.
  APPEND DATA.
ENDLOOP.
LOOP AT ITAB.
  DATA-W = ITAB-TIME.
  DATA-F = ITAB-AP1.
  APPEND DATA.
ENDLOOP.
LOOP AT ITAB.
  DATA-W = ITAB-TIME.
  DATA-F = ITAB-AP2.
  APPEND DATA.
ENDLOOP.
LOOP AT ITAB.
  DATA-W = ITAB-TIME.
  DATA-F = ITAB-AP3.
  APPEND DATA.
ENDLOOP.
LOOP AT TASKTYPE_RES.
  DATA-W = TASKTYPE_RES-TIME.
  DATA-F = TASKTYPE_RES-SUM1.
  APPEND DATA.
ENDLOOP.
LOOP AT TASKTYPE_RES.
  DATA-W = TASKTYPE_RES-TIME.
  DATA-F = TASKTYPE_RES-SUM2.
  APPEND DATA.
ENDLOOP.

DESCRIBE TABLE ITAB LINES LIN.
CLIN = LIN. CCLIN = CLIN. CCLIN(1) = '$'.
DATEC = 'USER LOAD '. DATEC+12 = DATE.

OPTS-C = CCLIN .APPEND OPTS.
OPTS-C = 'COLOR=1'.APPEND OPTS.
OPTS-C = 'thick=1'.APPEND OPTS.
OPTS-C = 'LTEXT='.APPEND OPTS.
OPTS-C = 'DTEXT='.APPEND OPTS.

OPTS-C = CCLIN .APPEND OPTS.
OPTS-C = 'COLOR=4'.APPEND OPTS.
OPTS-C = 'thick=1'.APPEND OPTS.
OPTS-C = 'LTEXT='.APPEND OPTS.
OPTS-C = 'DTEXT='.APPEND OPTS.

OPTS-C = CCLIN .APPEND OPTS.
OPTS-C = 'COLOR=2'.APPEND OPTS.
OPTS-C = 'thick=1'.APPEND OPTS.
OPTS-C = 'LTEXT='.APPEND OPTS.
OPTS-C = 'DTEXT='.APPEND OPTS.

OPTS-C = CCLIN .APPEND OPTS.
OPTS-C = 'COLOR=6'.APPEND OPTS.
OPTS-C = 'thick=1'.APPEND OPTS.
OPTS-C = 'LTEXT='.APPEND OPTS.
OPTS-C = 'DTEXT='.APPEND OPTS.

OPTS-C = CCLIN .APPEND OPTS.
OPTS-C = 'COLOR=3'.APPEND OPTS.
OPTS-C = 'thick=1'.APPEND OPTS.
OPTS-C = 'LTEXT='.APPEND OPTS.
OPTS-C = 'DTEXT='.APPEND OPTS.

DESCRIBE TABLE TASKTYPE_RES LINES LIN.
CLIN = LIN. CCLIN = CLIN. CCLIN(1) = '$'.

OPTS-C = CCLIN .APPEND OPTS.
OPTS-C = 'COLOR=7'.APPEND OPTS.
OPTS-C = 'thick=1'.APPEND OPTS.
OPTS-C = 'LTEXT='.APPEND OPTS.
OPTS-C = 'DTEXT='.APPEND OPTS.
OPTS = 'C_ART=1'.APPEND OPTS.
OPTS = 'CTYPE=5'.APPEND OPTS.

OPTS-C = CCLIN .APPEND OPTS.
OPTS-C = 'COLOR=8'.APPEND OPTS.
OPTS-C = 'thick=1'.APPEND OPTS.
OPTS-C = 'LTEXT='.APPEND OPTS.
OPTS-C = 'DTEXT='.APPEND OPTS.
OPTS = 'C_ART=1'.APPEND OPTS.
OPTS = 'CTYPE=5'.APPEND OPTS.

CALL FUNCTION 'STAT_GRAPH'
     EXPORTING
          TTEXT = DATEC
          UTEXT =
     'sum db ap1 ap2 ap3 dstp<1s sumdstp: wht gre blu red yel lblu gray'
          X_ART = 'LIN'
          Y_ART = 'LIN'
          SCALE = 'MAN'
          XRNGL = X1
          XRNGU = X2
          YRNGL = Y1
          YRNGU = Y2
          XTCKS = '15'
          YTCKS = '33'
          XDECS = '0'
          YDECS = '0'
     TABLES
          OPTS  = OPTS
          DATA  = DATA.

*---------------------------------------------------------------------*
*       FORM CALCULATE                                                *
*---------------------------------------------------------------------*
*       Collect the statistics data                                   *
*---------------------------------------------------------------------*
FORM CALCULATE.
  CLEAR TASKTYPE_STATISTIC.
  REFRESH TASKTYPE_STATISTIC.
  CALL FUNCTION 'SAPWL_WORKLOAD_GET_STATISTIC' DESTINATION 'zzzzzzzz'
       EXPORTING
            PERIODTYPE         = PERIODTYPE
            HOSTID             = HOSTID
            STARTDATE          = DATE
       TABLES
            TASKTYPE_STATISTIC = TASKTYPE_STATISTIC
       EXCEPTIONS
            NO_DATA_FOUND      = 1.
  LOOP AT TASKTYPE_STATISTIC.
    CLEAR TASKTYPE_SUM.
    IF TASKTYPE_STATISTIC-TASKTYPE = 'DIALOG'.
      MOVE-CORRESPONDING TASKTYPE_STATISTIC TO TASKTYPE_SUM.
      COLLECT TASKTYPE_SUM.
    ENDIF.
  ENDLOOP.
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 -> Security and Monitoring 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.