Paisleymll
MIS
Hello - I posted this issue a few years ago, without resolution. In doing a thorough search today. I found thread99-464072, this relates the issue to Arrays. In the scripts suffering worse from this issue, there are arrays, which are not my comfort zone. Also, in thread1-1273379, the same error is referenced with Global variables as the culprit. I use Global variable in most of my macro, along with a standard set of Modules. I am posting segments of code from a macro that runs every 15 minutes via a Shell call from task manager. Before the shell command is called, any extra processes (ebrun,ebedit,extra,ebmngr) are terminated. There doesn't appear to be an instigator for the error and it presents irregularly. I have many scripts that are prone to this error, but they run in a heavy traffic environment with a manual start, so restarting Extra is not a problem. This macro has a dedicated PC...
Code Sample :
'declarations specific to Array and array use
'User-Defined Type
Type IntSettings
Ste As String
Nm As String
Mon As String
Dtl As String
NOC As String
IVR AS String
TmFrm As String
Refd As String
End Type
'Helper Variables (Transaction Required)
Global Port() As IntSettings, ChkIntNm As String, ChkDesc As String, ChkStat As String, MonID As Integer, Btm As Object
Function FindInt(Ste As String, IntNm As String) As Integer
'Tests read Interface values against Monitor list
For Cnt = 0 To UBound(Port)
Test = Port(Cnt).Nm
If Ste = Port(Cnt).Ste And IntNm = Port(Cnt).Nm Then
FindInt = Cnt
Port(Cnt).Refd = "Y"
Exit Function
End If
Next Cnt
FindInt = 9999
End Function
Sub IntData
'Excel Objects
Dim appExcel As Object
Dim wbExcel As Object
Dim aSheet As Object
' - NEED TO TRAP NETWORK ERROR HERE
On Error GoTo ErrorHandler
FileCopy "\\infonet\sites\CorpIT\ProvisioningOSS\ICOMS Interface Script History\ICOMs Port Monitor.xls", _
"\\kstlmfps02\OMS\Provisioning_OSS\ITOPS-IDS\Interfaces\ICOMs Port Monitor.xls"
Set appExcel = CreateObject("Excel.Application")
Set wbExcel = appExcel.Workbooks.Open("\\kstlmfps02\OMS\Provisioning_OSS\ITOPS-IDS\Interfaces\ICOMs Port Monitor.xls")
Set aSheet = wbExcel.Sheets("ICOMs")
ReDim Port(aSheet.UsedRange.Rows.Count - 5)
For i = 5 To aSheet.UsedRange.Rows.Count
AID = i - 5
Test = Trim(aSheet.Cells(i, 3).Text)
Port(AID).Ste = Trim(aSheet.Cells(i, 2).Text)
Port(AID).Nm = Trim(aSheet.Cells(i, 3).Text)
Port(AID).Mon = Trim(aSheet.Cells(i, 4).Text)
Port(AID).Dtl = Trim(aSheet.Cells(i, 5).Text)
Port(AID).NOC = Trim(aSheet.Cells(i, 6).Text)
Port(AID).IVR = Trim(aSheet.Cells(i, 7).Text)
Port(AID).TmFrm = Trim(aSheet.Cells(i, 8).Text)
Next i
End Sub
Sub Main
'Input output file setup removed
'Session configuration removed
'To the GUTS
IntData
LastSite = "X"
'=====================================
'=====================================
'BEGIN Task execution Here
For Ste = 100 To 500 Step 100
Site = Trim(Str(Ste))
IntCnt = 0
Rw = 8
Pg = 0
Do
StartTrans:
Screentest = ICOMs.GetString(1, 36, 7)
If Screentest = "Sign On" Then 'Tests to see that Session is logged in
If Login = "N" Then GoTo ErrorEnd
ElseIf LastSite <> Site Then 'Tests to see that logged in Session is the correct Site
If ChgSite = "N" Then GoTo ErrorEnd
End If
RestartTrans:
If FindScreen = "N" Then GoTo ErrorEnd
If IntCnt = 0 And Pg = 0 Then TopPg1 = Trim(ICOMs.GetString(9, 6, 5))
Set Btm = ICOMs.Search("Bottom")
IntCnt = IntCnt + 1
ErrRec = "N"
ErrNOC = "N"
ErrIVR = "N"
ErrPortMnt = "N"
Comment = ""
Screentest = ""
ChkIntNm = ""
ChkDesc = ""
ChkStat = ""
MonID = 0
Test = Rw + IntCnt - (Pg * 12)
If Rw + IntCnt - (Pg * 12) = 21 Then
If Btm.Top = -1 Then
ICOMs.SendKeys ("<PF8>")
Sleep
'Screentest??? How???
Pg = Pg + 1
Set Btm = ICOMs.Search("Bottom")
Else
Exit Do 'No more records Bottom reached
End If
End If
CaptrIntInfo:
ChkIntNm = Trim(ICOMs.GetString(Rw + IntCnt - (Pg * 12), 6, 5))
ChkDesc = Trim(ICOMs.GetString(Rw + IntCnt - (Pg * 12), 12, 20))
ChkStat = ICOMs.GetString(Rw + IntCnt - (Pg * 12), 35, 4)
' Test captured data - Execute a refresh
If ChkIntNm = "" And Btm.Top <> -1 Then Exit Do ' No More Interfaces
If ChkStat = "****" Then
ICOMs.SendKeys ("<PA1><PF5>")
Sleep
Screentest = Trim(ICOMs.GetString(9, 35, 1))
If Screentest = "*" Then
Comment = "Refresh did not clear issue"
rc% = MsgBox(Comment, "ERROR")
Stop
ElseIf Pg <> 0 and TopPg1 = Trim(ICOMs.GetString(9, 6, 5))Then
For Dwn = 1 to Pg
ICOMs.SendKeys ("<PF8>")
Sleep
Next Dwn
End If
GoTo CaptrIntInfo
ElseIf ChkStat = "" Then
If Btm.Top <> -1 Then
'End of list reached
Exit Do 'No more records Bottom reached
Else
Comment = "Unexpected Blank Interface not at bottom"
ErrScrape (1)
End If
End If
' Find Port in Monitor Doc
MonID = FindInt(Site, ChkIntNm)
If MonID = 9999 Then
'Port Not Found
If TmeTst = -1 And DteTst = -1 Then
Comment = Site & "-" & ChkIntNm & "-" & ChkDesc
ErrPortMnt = "Y"
End If
GoTo ErrorLog
'Write Message to ExcNm - send to OSS - Monday - Friday 8 - 5 PM
End If
'Evaluate Port Monitor Triggers -
If ChkStat = "MSGW" Or ChkStat = "NO" Then
Comment = "Site " & Site & " " & Now() & " " & ChkIntNm & " " & ChkDesc & " is in status " & ChkStat & " check it out!!!"
If UCase(Port(MonID).Mon) = "Y" Then ErrRec = "Y"
If UCase(Port(MonID).NOC) = "Y" Then ErrNOC = "Y"
If UCase(Port(MonID).IVR) = "Y" Then ErrIVR = "Y"
End If
'For NOC and Detail view on Select OSS/HelpDesk Ports
If UCase(Port(MonID).Dtl) = "Y" Or UCase(Port(MonID).NOC) = "Y" Or UCase(Port(MonID).IVR) = "Y"Then
ICOMs.MoveTo Rw + IntCnt - (Pg * 12), 2
ICOMs.SendKeys ("7<Enter>")
Sleep
Screentest = Trim(ICOMs.GetString(1, 2, 8))
If Screentest <> "TRFDSP" Then
ErrScrape (1)
Stop
End If
'When a time frame is needed - then the search for 2 minutes ago is removed and replaced with 2 hours ago
If Port(MonID).TmFrm = "Y" Then
CalcTm = Time
CalcDate = Date
CalcHr = Hour(CalcTm)
If CalcHr = 0 Or CalcHr = 1 Then
CalcHr = 24 + CalcHr
CalcDate = CalcDate - 1
End If
SrchDate = Format(CVar(CalcDate), "mmddyy")
SrchTime = Format(CalcHr - 2, "00") & Format(CVar(CalcTm), "nnss")
ICOMs.MoveTo 4, 2
ICOMs.SendKeys ("<EraseEOF>" & SrchDate)
ICOMs.MoveTo 4, 11
ICOMs.SendKeys ("<EraseEOF>" & SrchTime)
ICOMs.SendKeys ("<Enter>")
Sleep
Screentest = Trim(ICOMs.GetString(1, 2, 8))
If Screentest <> "TRFDSP" Then
Comment = "Detail Screen not found after Time Update"
ErrScrape (1)
Stop
End If
End If
ChkDtl = Trim(ICOMs.GetString(9, 3, 7))
If ChkDtl = "" Then
Comment = "Site " & Site & " " & Now() & " " & ChkIntNm & " " & ChkDesc & " is in status " & ChkStat & " and shows no transactions. Check It Out!!!"
If UCase(Port(MonID).Mon) = "Y" Then ErrRec = "Y"
If UCase(Port(MonID).NOC) = "Y" Then ErrNOC = "Y"
If UCase(Port(MonID).IVR) = "Y" Then ErrIVR = "Y"
End If
ICOMs.SendKeys ("<RESET>")
ICOMs.SendKeys ("<PA1><PF3>")
Call Sleep
ICOMs.SendKeys ("<PA1><PF5>")
Sleep
End If
ErrorLog:
If Comment = "" Then Comment = "Issue Not Found"
lastintname = ChkIntNm + " - " + Str(IntCnt) + " - " + Str(Pg) + " - " + Str(test)
If ErrRec = "Y" Then Print #OSSHelpNo, Comment
If ErrNOC = "Y" Then Print #NOCNo, Comment
If ErrIVR = "Y" Then Print #IVRNo, Comment
If ErrPortMnt = "Y" Then
If Prt = 0 Then
Call PortMonHdr
Print #PortMntNo, "PORT(S) NOT FOUND IN 'ICOMs Port Monitor.xls'"
End If
Print #PortMntNo, Comment
Prt = Prt + 1
End If
LastSite = Site
Loop
Next Ste
End Site
If FindMenu = "N" Then GoTo EndAlready
ICOMs.MoveTo 21, 15
ICOMs.SendKeys ("<Reset>")
ICOMs.SendKeys ("90<Enter>") 'at any Menu:
Sleep
EndAlready:
'Reset Session in case Logoff failed
Sess0.Connected = False
pause (2)
Sess0.Close
PrtStrt = Prt
If TmeTst = -1 And DteTst = -1 Then '
For Cnt = 0 To UBound(Port)
If Port(Cnt).Refd <> "Y" Then
If Prt = 0 Then
Call PortMonHdr
Print #PortMntNo, "PORT(S) FROM 'ICOMs Port Monitor.xls' NOT FOUND IN BILLING"
Elseif PrtStrt = Prt Then
Print #PortMntNo, "PORT(S) FROM 'ICOMs Port Monitor.xls' NOT FOUND IN BILLING"
End If
Comment = Port(Cnt).Ste & "-" & Port(Cnt).Nm & "-NOT FOUND"
Print #PortMntNo, Comment
Prt = Prt + 1
End If
Next Cnt
End If
End Sub
Code Sample :
'declarations specific to Array and array use
'User-Defined Type
Type IntSettings
Ste As String
Nm As String
Mon As String
Dtl As String
NOC As String
IVR AS String
TmFrm As String
Refd As String
End Type
'Helper Variables (Transaction Required)
Global Port() As IntSettings, ChkIntNm As String, ChkDesc As String, ChkStat As String, MonID As Integer, Btm As Object
Function FindInt(Ste As String, IntNm As String) As Integer
'Tests read Interface values against Monitor list
For Cnt = 0 To UBound(Port)
Test = Port(Cnt).Nm
If Ste = Port(Cnt).Ste And IntNm = Port(Cnt).Nm Then
FindInt = Cnt
Port(Cnt).Refd = "Y"
Exit Function
End If
Next Cnt
FindInt = 9999
End Function
Sub IntData
'Excel Objects
Dim appExcel As Object
Dim wbExcel As Object
Dim aSheet As Object
' - NEED TO TRAP NETWORK ERROR HERE
On Error GoTo ErrorHandler
FileCopy "\\infonet\sites\CorpIT\ProvisioningOSS\ICOMS Interface Script History\ICOMs Port Monitor.xls", _
"\\kstlmfps02\OMS\Provisioning_OSS\ITOPS-IDS\Interfaces\ICOMs Port Monitor.xls"
Set appExcel = CreateObject("Excel.Application")
Set wbExcel = appExcel.Workbooks.Open("\\kstlmfps02\OMS\Provisioning_OSS\ITOPS-IDS\Interfaces\ICOMs Port Monitor.xls")
Set aSheet = wbExcel.Sheets("ICOMs")
ReDim Port(aSheet.UsedRange.Rows.Count - 5)
For i = 5 To aSheet.UsedRange.Rows.Count
AID = i - 5
Test = Trim(aSheet.Cells(i, 3).Text)
Port(AID).Ste = Trim(aSheet.Cells(i, 2).Text)
Port(AID).Nm = Trim(aSheet.Cells(i, 3).Text)
Port(AID).Mon = Trim(aSheet.Cells(i, 4).Text)
Port(AID).Dtl = Trim(aSheet.Cells(i, 5).Text)
Port(AID).NOC = Trim(aSheet.Cells(i, 6).Text)
Port(AID).IVR = Trim(aSheet.Cells(i, 7).Text)
Port(AID).TmFrm = Trim(aSheet.Cells(i, 8).Text)
Next i
End Sub
Sub Main
'Input output file setup removed
'Session configuration removed
'To the GUTS
IntData
LastSite = "X"
'=====================================
'=====================================
'BEGIN Task execution Here
For Ste = 100 To 500 Step 100
Site = Trim(Str(Ste))
IntCnt = 0
Rw = 8
Pg = 0
Do
StartTrans:
Screentest = ICOMs.GetString(1, 36, 7)
If Screentest = "Sign On" Then 'Tests to see that Session is logged in
If Login = "N" Then GoTo ErrorEnd
ElseIf LastSite <> Site Then 'Tests to see that logged in Session is the correct Site
If ChgSite = "N" Then GoTo ErrorEnd
End If
RestartTrans:
If FindScreen = "N" Then GoTo ErrorEnd
If IntCnt = 0 And Pg = 0 Then TopPg1 = Trim(ICOMs.GetString(9, 6, 5))
Set Btm = ICOMs.Search("Bottom")
IntCnt = IntCnt + 1
ErrRec = "N"
ErrNOC = "N"
ErrIVR = "N"
ErrPortMnt = "N"
Comment = ""
Screentest = ""
ChkIntNm = ""
ChkDesc = ""
ChkStat = ""
MonID = 0
Test = Rw + IntCnt - (Pg * 12)
If Rw + IntCnt - (Pg * 12) = 21 Then
If Btm.Top = -1 Then
ICOMs.SendKeys ("<PF8>")
Sleep
'Screentest??? How???
Pg = Pg + 1
Set Btm = ICOMs.Search("Bottom")
Else
Exit Do 'No more records Bottom reached
End If
End If
CaptrIntInfo:
ChkIntNm = Trim(ICOMs.GetString(Rw + IntCnt - (Pg * 12), 6, 5))
ChkDesc = Trim(ICOMs.GetString(Rw + IntCnt - (Pg * 12), 12, 20))
ChkStat = ICOMs.GetString(Rw + IntCnt - (Pg * 12), 35, 4)
' Test captured data - Execute a refresh
If ChkIntNm = "" And Btm.Top <> -1 Then Exit Do ' No More Interfaces
If ChkStat = "****" Then
ICOMs.SendKeys ("<PA1><PF5>")
Sleep
Screentest = Trim(ICOMs.GetString(9, 35, 1))
If Screentest = "*" Then
Comment = "Refresh did not clear issue"
rc% = MsgBox(Comment, "ERROR")
Stop
ElseIf Pg <> 0 and TopPg1 = Trim(ICOMs.GetString(9, 6, 5))Then
For Dwn = 1 to Pg
ICOMs.SendKeys ("<PF8>")
Sleep
Next Dwn
End If
GoTo CaptrIntInfo
ElseIf ChkStat = "" Then
If Btm.Top <> -1 Then
'End of list reached
Exit Do 'No more records Bottom reached
Else
Comment = "Unexpected Blank Interface not at bottom"
ErrScrape (1)
End If
End If
' Find Port in Monitor Doc
MonID = FindInt(Site, ChkIntNm)
If MonID = 9999 Then
'Port Not Found
If TmeTst = -1 And DteTst = -1 Then
Comment = Site & "-" & ChkIntNm & "-" & ChkDesc
ErrPortMnt = "Y"
End If
GoTo ErrorLog
'Write Message to ExcNm - send to OSS - Monday - Friday 8 - 5 PM
End If
'Evaluate Port Monitor Triggers -
If ChkStat = "MSGW" Or ChkStat = "NO" Then
Comment = "Site " & Site & " " & Now() & " " & ChkIntNm & " " & ChkDesc & " is in status " & ChkStat & " check it out!!!"
If UCase(Port(MonID).Mon) = "Y" Then ErrRec = "Y"
If UCase(Port(MonID).NOC) = "Y" Then ErrNOC = "Y"
If UCase(Port(MonID).IVR) = "Y" Then ErrIVR = "Y"
End If
'For NOC and Detail view on Select OSS/HelpDesk Ports
If UCase(Port(MonID).Dtl) = "Y" Or UCase(Port(MonID).NOC) = "Y" Or UCase(Port(MonID).IVR) = "Y"Then
ICOMs.MoveTo Rw + IntCnt - (Pg * 12), 2
ICOMs.SendKeys ("7<Enter>")
Sleep
Screentest = Trim(ICOMs.GetString(1, 2, 8))
If Screentest <> "TRFDSP" Then
ErrScrape (1)
Stop
End If
'When a time frame is needed - then the search for 2 minutes ago is removed and replaced with 2 hours ago
If Port(MonID).TmFrm = "Y" Then
CalcTm = Time
CalcDate = Date
CalcHr = Hour(CalcTm)
If CalcHr = 0 Or CalcHr = 1 Then
CalcHr = 24 + CalcHr
CalcDate = CalcDate - 1
End If
SrchDate = Format(CVar(CalcDate), "mmddyy")
SrchTime = Format(CalcHr - 2, "00") & Format(CVar(CalcTm), "nnss")
ICOMs.MoveTo 4, 2
ICOMs.SendKeys ("<EraseEOF>" & SrchDate)
ICOMs.MoveTo 4, 11
ICOMs.SendKeys ("<EraseEOF>" & SrchTime)
ICOMs.SendKeys ("<Enter>")
Sleep
Screentest = Trim(ICOMs.GetString(1, 2, 8))
If Screentest <> "TRFDSP" Then
Comment = "Detail Screen not found after Time Update"
ErrScrape (1)
Stop
End If
End If
ChkDtl = Trim(ICOMs.GetString(9, 3, 7))
If ChkDtl = "" Then
Comment = "Site " & Site & " " & Now() & " " & ChkIntNm & " " & ChkDesc & " is in status " & ChkStat & " and shows no transactions. Check It Out!!!"
If UCase(Port(MonID).Mon) = "Y" Then ErrRec = "Y"
If UCase(Port(MonID).NOC) = "Y" Then ErrNOC = "Y"
If UCase(Port(MonID).IVR) = "Y" Then ErrIVR = "Y"
End If
ICOMs.SendKeys ("<RESET>")
ICOMs.SendKeys ("<PA1><PF3>")
Call Sleep
ICOMs.SendKeys ("<PA1><PF5>")
Sleep
End If
ErrorLog:
If Comment = "" Then Comment = "Issue Not Found"
lastintname = ChkIntNm + " - " + Str(IntCnt) + " - " + Str(Pg) + " - " + Str(test)
If ErrRec = "Y" Then Print #OSSHelpNo, Comment
If ErrNOC = "Y" Then Print #NOCNo, Comment
If ErrIVR = "Y" Then Print #IVRNo, Comment
If ErrPortMnt = "Y" Then
If Prt = 0 Then
Call PortMonHdr
Print #PortMntNo, "PORT(S) NOT FOUND IN 'ICOMs Port Monitor.xls'"
End If
Print #PortMntNo, Comment
Prt = Prt + 1
End If
LastSite = Site
Loop
Next Ste
End Site
If FindMenu = "N" Then GoTo EndAlready
ICOMs.MoveTo 21, 15
ICOMs.SendKeys ("<Reset>")
ICOMs.SendKeys ("90<Enter>") 'at any Menu:
Sleep
EndAlready:
'Reset Session in case Logoff failed
Sess0.Connected = False
pause (2)
Sess0.Close
PrtStrt = Prt
If TmeTst = -1 And DteTst = -1 Then '
For Cnt = 0 To UBound(Port)
If Port(Cnt).Refd <> "Y" Then
If Prt = 0 Then
Call PortMonHdr
Print #PortMntNo, "PORT(S) FROM 'ICOMs Port Monitor.xls' NOT FOUND IN BILLING"
Elseif PrtStrt = Prt Then
Print #PortMntNo, "PORT(S) FROM 'ICOMs Port Monitor.xls' NOT FOUND IN BILLING"
End If
Comment = Port(Cnt).Ste & "-" & Port(Cnt).Nm & "-NOT FOUND"
Print #PortMntNo, Comment
Prt = Prt + 1
End If
Next Cnt
End If
End Sub