Pages

Saturday, 29 August 2015

How to fetch ST03N data into excel

How to fetch ST03N data into excel

As part of BASIS administration we need to perform workload analysis, response time, db time etc, We will see how to fetch this data for ST03N from any ABAP based SAP server. We have seen in previous documents how to login to SAP and call functions.

We will use FM SWNC_COLLECTOR_GET_AGGREGATES which is a remote enabled function module, there are others as well but this one is much easier to call. Remember this function will give data older than a day

Input Parameters :
COMPONENT: Intance Name or Total for all intances
PERIODTYPE: D - Day
                        M - Month
                        W - Week
PERIODSTRT: Start Date
SUMMARY_ONLY: Optional X
FACTOR : 1000


Output: The output is in form of 12 to 15 Tables, We are using only one UserTCODE, this table gives us output as per each tcode. The table has 43 cols of which below are few important ones
TASKTYPE : Take type
COUNT: Number of Steps
RESPTI : Response Time




Sample Code
 Sub Zst03N_USERTCODE(R3 As Object)
' calling next func
Set muFunc = R3.Add("SWNC_COLLECTOR_GET_AGGREGATES")
'loading SAP functions input parameters
Dim COMPONENT, PERIODTYPE, PERIODSTRT, SUMMARY_ONLY, FACTOR As Object
Set COMPONENT = muFunc.exports("COMPONENT")
COMPONENT.Value = Sheets("Main").Cells(6, 6)
'Set ASSIGNDSYS = muFunc.exports("ASSIGNDSYS")
'ASSIGNDSYS.Value = Sheets("Main").Cells(3, 3)
Set PERIODTYPE = muFunc.exports("PERIODTYPE")
PERIODTYPE.Value = Sheets("Main").Cells(7, 6)
Set PERIODSTRT = muFunc.exports("PERIODSTRT")
PERIODSTRT.Value = Sheets("Main").Cells(8, 6)
'"14/05/2012"
Set FACTOR = muFunc.exports("FACTOR")
'FACTOR.Value = "1000"


'Set SUMMARY_ONLY = muFunc.exports("SUMMARY_ONLY")
'SUMMARY_ONLY.Value = ""
' calling SAP Func
If muFunc.call = False Then
    MsgBox muFunc.Exception
End If
Dim USERTCODE As Object
Set USERTCODE = muFunc.Tables("USERTCODE")


Xrange = USERTCODE.Rows.Count


For i = 1 To Xrange
j = i + 1
    Sheets("USERTCODE").Cells(j, 2) = USERTCODE.Value(i, "TASKTYPE")
    Sheets("USERTCODE").Cells(j, 3) = USERTCODE.Value(i, "ACCOUNT")
    Sheets("USERTCODE").Cells(j, 4) = USERTCODE.Value(i, "ENTRY_ID")
    Sheets("USERTCODE").Cells(j, 5) = USERTCODE.Value(i, "COUNT")
    Sheets("USERTCODE").Cells(j, 6) = USERTCODE.Value(i, "DCOUNT")
    Sheets("USERTCODE").Cells(j, 7) = USERTCODE.Value(i, "UCOUNT")
    Sheets("USERTCODE").Cells(j, 8) = USERTCODE.Value(i, "BCOUNT")
    Sheets("USERTCODE").Cells(j, 9) = USERTCODE.Value(i, "ECOUNT")
    Sheets("USERTCODE").Cells(j, 10) = USERTCODE.Value(i, "SCOUNT")
    Sheets("USERTCODE").Cells(j, 11) = USERTCODE.Value(i, "LUW_COUNT")
    Sheets("USERTCODE").Cells(j, 12) = USERTCODE.Value(i, "TMBYTESIN")
    Sheets("USERTCODE").Cells(j, 13) = USERTCODE.Value(i, "TMBYTESOUT")
    Sheets("USERTCODE").Cells(j, 14) = USERTCODE.Value(i, "RESPTI")
    Sheets("USERTCODE").Cells(j, 15) = USERTCODE.Value(i, "PROCTI")
    Sheets("USERTCODE").Cells(j, 16) = USERTCODE.Value(i, "CPUTI")
    Sheets("USERTCODE").Cells(j, 17) = USERTCODE.Value(i, "QUEUETI")
    Sheets("USERTCODE").Cells(j, 18) = USERTCODE.Value(i, "ROLLWAITTI")
    Sheets("USERTCODE").Cells(j, 19) = USERTCODE.Value(i, "GUITIME")
    Sheets("USERTCODE").Cells(j, 20) = USERTCODE.Value(i, "GUICNT")
    Sheets("USERTCODE").Cells(j, 21) = USERTCODE.Value(i, "GUINETTIME")
    Sheets("USERTCODE").Cells(j, 22) = USERTCODE.Value(i, "DBP_COUNT")
    Sheets("USERTCODE").Cells(j, 23) = USERTCODE.Value(i, "DBP_TIME")
    Sheets("USERTCODE").Cells(j, 24) = USERTCODE.Value(i, "READDIRCNT")
    Sheets("USERTCODE").Cells(j, 25) = USERTCODE.Value(i, "READDIRTI")
    Sheets("USERTCODE").Cells(j, 26) = USERTCODE.Value(i, "READDIRBUF")
    Sheets("USERTCODE").Cells(j, 27) = USERTCODE.Value(i, "READDIRREC")
    Sheets("USERTCODE").Cells(j, 28) = USERTCODE.Value(i, "READSEQCNT")
    Sheets("USERTCODE").Cells(j, 29) = USERTCODE.Value(i, "READSEQTI")
    Sheets("USERTCODE").Cells(j, 30) = USERTCODE.Value(i, "READSEQBUF")
    Sheets("USERTCODE").Cells(j, 31) = USERTCODE.Value(i, "READSEQREC")
    Sheets("USERTCODE").Cells(j, 32) = USERTCODE.Value(i, "CHNGCNT")
    Sheets("USERTCODE").Cells(j, 33) = USERTCODE.Value(i, "CHNGTI")
    Sheets("USERTCODE").Cells(j, 34) = USERTCODE.Value(i, "CHNGREC")
    Sheets("USERTCODE").Cells(j, 35) = USERTCODE.Value(i, "PHYREADCNT")
    Sheets("USERTCODE").Cells(j, 36) = USERTCODE.Value(i, "PHYCHNGREC")
    Sheets("USERTCODE").Cells(j, 37) = USERTCODE.Value(i, "PHYCALLS")
    Sheets("USERTCODE").Cells(j, 38) = USERTCODE.Value(i, "DSQLCNT")
    Sheets("USERTCODE").Cells(j, 39) = USERTCODE.Value(i, "QUECNT")
    Sheets("USERTCODE").Cells(j, 40) = USERTCODE.Value(i, "CPICCNT")
    Sheets("USERTCODE").Cells(j, 41) = USERTCODE.Value(i, "SLI_CNT")
    Sheets("USERTCODE").Cells(j, 42) = USERTCODE.Value(i, "VMC_CALL_COUNT")
    Sheets("USERTCODE").Cells(j, 43) = USERTCODE.Value(i, "VMC_CPU_TIME")
    Sheets("USERTCODE").Cells(j, 44) = USERTCODE.Value(i, "VMC_ELAP_TIME")


Next
End Sub


Sample Output



Compared to Original


Sample Code : download

1 comment: