Using basic capabilities : Overview of using basic capabilities : Analytics : Analytic examples in System Architect : BPMN process costs
  
BPMN process costs
This analytic, when dropped onto a (BPMN) Business Process diagram, automatically calculates Activity Based Costs and rolls up into the diagram property Total Cost. The analytic measures the process cost against the Total Cost for all processes in the diagram. The gauge for each process shows the percentage of the total cost that the process makes up.
To run this analytic
1 Specify process costs for processes in a BPMN diagram.
2 Right-click the diagram workspace and select Show Analytic Depictions from the popup dialog.
3 From the Explorer, in the Definitions group on the All Methods tab, find the Analytic definition type, and select the BPMN Process Costs analytic definition.
4 Drag the BPMN Process Costs analytic onto the diagram workspace of the open BPMN Business Process diagram.
Example source for analytic macro
Sub ActivityBasedCosts()
' This analytic macro calculates Activity Based Costs for each process and rolls them up
' into the diagram property Total Cost. The analytic measures the process cost against
' the Total Cost of the diagram. The gauge for each process shows the percentage of the
' total cost that the process makes up.
' Only for current diagram
Dim oCurrentDgm As Diagram
Dim intCost As Integer
Dim colProcesses As SAObjects
Dim oProcessDef As Definition
Dim oProcessSym As symbol
Dim strFrequency As String
Dim colCostPool As OfCollection
Dim oCostPoolDef As Definition
Dim strVariable As String
Dim strCost As String
Dim strTotalCost As String
Dim strTotalDiagramCost As String
Dim sa As Application
Dim percCost As Single
Dim proccost As Double
Dim diagcost As Double

On Error Resume Next
Set sa = New Application
Set oCurrentDgm = sa.Encyclopedia.GetCurrentDiagram

If oCurrentDgm Is Nothing Then
MsgBox SAXRes.GetLocalString(IDS_SAAutoAnalytics____adiagrammustbeopentorunthisanalytic), vbExclamation
Else
strTotalDiagramCost = vbNullString
' get each process on the diagram
If oCurrentDgm.SAType = GTDM2OV5B_BP Then
Set colProcesses = oCurrentDgm.GetFilteredSymbols(vbNullString, ETDM2OV05B_BPPROCESS)
Else
Set colProcesses = oCurrentDgm.GetFilteredSymbols(vbNullString, ETBPPROCESS)
End If
colProcesses.ReadAll
For Each oProcessSym In colProcesses
strTotalCost = vbNullString
Set oProcessDef = oProcessSym.Definition
' get the frequency of the process
strFrequency = oProcessDef.GetProperty("Runs per Cycle") 'DEV_STRING
' get the cost pools
Set colCostPool = oProcessDef.GetPropertyAsCollection("Activity Cost Pool") 'DEV_STRING
If colCostPool.Count > 0 Then
For Each oCostPoolDef In colCostPool
strVariable = oCostPoolDef.GetProperty("Variable") 'DEV_STRING
strCost = oCostPoolDef.GetProperty("Cost") 'DEV_STRING
If strVariable = "T" Then 'DEV_STRING
' multiply cost by frequency
strCost = Str(Val(strCost) * Val(strFrequency))
End If
' add each item in collection to process total
strTotalCost = Str(Val(strTotalCost) + Val(strCost))
Next oCostPoolDef
End If
oProcessDef.SetProperty "Total Cost", Trim(strTotalCost) 'DEV_STRING
oProcessDef.Save
strTotalDiagramCost = Str(Val(strTotalCost) + Val(strTotalDiagramCost))
Next oProcessSym

oCurrentDgm.SetProperty "Total Cost", Trim(strTotalDiagramCost) 'DEV_STRING

' go through processes and work out the cost of processes as a percentage of total diagram cost
For Each oProcessSym In colProcesses
proccost = Val(oProcessSym.Definition.GetProperty("Total Cost")) 'DEV_STRING
diagcost = Val(oCurrentDgm.GetProperty("Total Cost")) 'DEV_STRING
percCost = proccost / diagcost + 1

' set gauge according to value
Select Case percCost
Case 1 To 1.1
oProcessSym.SetProperty "Analytic Gauge", "0-10" 'DEV_STRING
Case 1.1 To 1.2
oProcessSym.SetProperty "Analytic Gauge", "11-20" 'DEV_STRING
Case 1.2 To 1.3
oProcessSym.SetProperty "Analytic Gauge", "21-30" 'DEV_STRING
Case 1.3 To 1.4
oProcessSym.SetProperty "Analytic Gauge", "31-40" 'DEV_STRING
Case 1.4 To 1.5
oProcessSym.SetProperty "Analytic Gauge", "41-50" 'DEV_STRING
Case 1.5 To 1.6
oProcessSym.SetProperty "Analytic Gauge", "51-60" 'DEV_STRING
Case 1.6 To 1.7
oProcessSym.SetProperty "Analytic Gauge", "61-70" 'DEV_STRING
Case 1.7 To 1.8
oProcessSym.SetProperty "Analytic Gauge", "71-80" 'DEV_STRING
Case 1.8 To 1.9
oProcessSym.SetProperty "Analytic Gauge", "81-90" 'DEV_STRING
Case 1.9 To 2
oProcessSym.SetProperty "Analytic Gauge", "91-100" 'DEV_STRING
Case Else
oProcessSym.SetProperty "Analytic Gauge", "None" 'DEV_STRING
End Select

If proccost = 0 Then
oProcessSym.SetProperty "Analytic Gauge", "None" 'DEV_STRING
End If
oProcessSym.Save
Next oProcessSym
RefreshDiagram
oCurrentDgm.Save
End If

Set sa = Nothing
End Sub

Private Sub RefreshDiagram()
Dim ISA As ISAImf
On Error Resume Next
Set ISA = Application.Interface("ISAImf") 'DEV_STRING
ISA.SAExecuteMenuCommand 310
End Sub
See also
Analytic examples in System Architect