I have an agent signed by me that runs on the server, it runs fine if called manually but not on shedule. The agent log says sucessully runs but I got the views empty.This agent removes the records from 3 views and gets the item master from the AS400 and then rebuilding the same views.
maybe looking the my code will help find my problem.
Thanks
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim view09 As NotesView
Dim view95 As NotesView
Dim doc As NotesDocument
Dim RetCode As Integer
Dim dataSource As String
Dim userName As String
Dim userPassword As String
Dim con As New ODBCConnection
Dim dsn As String
Dim msg As String
Dim dsnames As Variant
Dim fields As Variant
Dim FieldCount As Integer
Dim qry As New ODBCquery
Dim strSQL As String
Dim result As New ODBCResultSet
dataSource = "AS400U"
userName = "pvcnotes"
userPassword = "pvcnotespw"
'notes database declarations for view
Const ndbViewName = "Parts"
Const ndbViewName09 = "09Parts"
Const ndbViewName95 = "95Parts"
Const ndbFormName = "Parts"
Set db = session.CurrentDatabase
Set view=db.GetView(ndbViewName)
Set view09=db.GetView(ndbViewName09)
Set view95=db.GetView(ndbViewName95)
'Delete all records from view-Parts
'Set db = session.CurrentDatabase
'Set view = db.GetView("Parts")
'Set view09 = db.GetView("09Parts")
'Set view95 = db.GetView("Parts")
view.AutoUpdate = False
view09.AutoUpdate = False
view95.AutoUpdate = False
view.AllEntries.removeall(True)
view09.AllEntries.removeall(True)
view95.AllEntries.removeall(True)
view.AutoUpdate = True
view09.AutoUpdate = True
view95.AutoUpdate = True
Call view.Refresh
Call view09.Refresh
Call view95.Refresh
'ODBC Connect
Set qry.Connection = con
Set result.Query = qry
Print "LS:DO LSX Version: "& con.GetLSDOMasterRevision
RetCode = con.ConnectTo(dataSource,userName,userPassword)
If RetCode Then
Print "ODBC Connection to " & dataSource & " opened."
Else
Messagebox "The ODBC connection could not be established.Exiting."
Messagebox "Error number: & con.GetError & Chr(13) & con.GetExtendedError"
End If
strSQL = "SELECT ITNR1I, TEXTPD, ISLL02, CMPN1N "
strSQL=strSQL & "FROM CASPDTAP.GIDPF01I a"
strSQL=strSQL & " left join CCMPDTAP.PV1PF0PD b on ITNR1I = ITNRPD"
strSQL=strSQL & " left join CASPDTAP.GIDPF302 c on ITNR1I = IITM02"
strSQL=strSQL & " left join CASPDTAP.GIDPF01N d on ITNR1I = ITNR1N and CMPN1N != '01' and PRDT1N = 'E'"
strSQL=strSQL & " where ITMS1I = 'A'"
strSQL=strSQL & " and ITNR1I like '__-____-__-____%' "
strSQL=strSQL & " and substr(ITNR1I,1,2) in ('01','07','09','21','27', '30','32','42','95')"
strSQL=strSQL & " and (IDTV02 = (select max(IDTV02) from CASPDTAP.GIDPF302 aa"
strSQL=strSQL & " where aa.IITM02 = a.ITNR1I) or IDTV02 is null) "
qry.SQL = strSQL
result.Execute
'Create View
Dim subString As String
If result.IsResultSetAvailable Then
Do
result.NextRow
Set doc=db.CreateDocument
doc.Form=ndbFormName
doc.Part=result.GetValue("ITNR1I")
doc.DESCRIP= result.GetValue("TEXTPD")
doc.SALEPRICE=result.GetValue("ISLL02")
doc.Po=result.GetValue("CMPN1N")
Call doc.Save(True,False)
Loop Until result.IsEndOfData
result.Close(DB_CLOSE)
End If
con.Disconnect
Call view.Refresh
Call view09.Refresh
Call view95.Refresh
' end create view
End Sub