AgEnT To Generate TeXT filE (.txt) RePoRt

Monday, March 17, 2008

Call from Button : Generate Report. This report will be used to import data to other system. (eg. Pay roll)
View: Report view
(Form selection Field Status := "Approved")
Trigger from: AgentlistSelection
Target: None
Programming Language: Lotus Script

Sub Initialize
Dim temp1 As String
Dim temp2 As String
Dim temp3 As String
Dim temp4 As String
Dim temp5 As String
Dim temp6 As String

temp1 = "OT 1"
temp2 = "OT 0.25"
temp3 = "OT 0.20"
temp4 = "3R"
temp5 = "2R"
temp6 = "1.5"

Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim emplno As String
Dim emplname As String
Dim ot1 As Double
Dim ot2 As Double
Dim ot3 As Double
Dim ot4 As Double
Dim ot5 As Double
Dim ot6 As Double
Dim filestr As String
filestr = "C:\export.txt"
Set outputStream =session.CreateStream
outputStream.Open (filestr)
outputStream.Truncate
Dim delim As String
delim = "|"
outputStream.WriteText ("EMPL NUMBER" + delim + "EMPL NAME" + delim + temp1 + delim + temp2 + delim + temp3 + delim + temp4 + delim + temp5 + delim + temp6 +Chr(13)+Chr(10))
Dim view As notesview
Set view = db.GetView("lkSvByEmployee")

Dim doc As notesdocument
Set doc = view.GetFirstDocument

emplname = ""

While Not (doc Is Nothing)
If doc.Status(0) = "Approved" Then
If emplname <> doc.emp(0) Then
emplno = Cstr(doc.emp_num(0))
emplname = doc.emp(0)
Select Case Trim(doc.cat_1(0))
Case temp1 : ot1 = ot1 +doc.TotDay(0)
Case temp2 : ot2 = ot2 +doc.TotDay(0)
Case temp3 : ot3 = ot3 +doc.TotDay(0)
Case temp4 : ot4 = ot4 +doc.TotDay(0)
Case temp5 : ot5 = ot5 +doc.TotDay(0)
Case temp6 : ot6 = ot6 +doc.TotDay(0)
End Select
doc.status = "Processed"
Call doc.Save(0,0)
Else
Select Case Trim(doc.cat_1(0) )
Case temp1 : ot1 = ot1 +doc.TotDay(0)
Case temp2 : ot2 = ot2 +doc.TotDay(0)
Case temp3 : ot3 = ot3 +doc.TotDay(0)
Case temp4 : ot4 = ot4 +doc.TotDay(0)
Case temp5 : ot5 = ot5 +doc.TotDay(0)
Case temp6 : ot6 = ot6 +doc.TotDay(0)
End Select
doc.status = "Processed"
Call doc.Save(0,0)
End If
'outputStream.WriteText (emplno + delim + emplname + delim + Cstr(ot1) + delim + Cstr(ot2) + delim + Cstr(ot3) + delim + Cstr(ot4) + delim + Cstr(ot5) + delim + Cstr(ot6) +Chr(13)+Chr(10))
End If

Set doc = view.GetNextDocument( doc )


If Not (doc Is Nothing) Then
If doc.Status(0) = "Approved" Then
If emplname <> doc.emp(0) Then
outputStream.WriteText (emplno + delim + emplname + delim + Cstr(ot1) + delim + Cstr(ot2) + delim + Cstr(ot3) + delim + Cstr(ot4) + delim + Cstr(ot5) + delim + Cstr(ot6) +Chr(13)+Chr(10))
ot1 = 0
ot2 = 0
ot3 = 0
ot4 = 0
ot5 = 0
ot6 = 0
End If
End If
Else
If (emplno <> "" And emplname <> "" ) Then
outputStream.WriteText (emplno + delim + emplname + delim + Cstr(ot1) + delim + Cstr(ot2) + delim + Cstr(ot3) + delim + Cstr(ot4) + delim + Cstr(ot5) + delim + Cstr(ot6) +Chr(13)+Chr(10))
End If
End If


Wend

0 comments: