I have a working and verified solution (Vantage 6.1).
My bank provided me with the specs for the ACH files. I wrote a program
(vbscript) to convert Vantage output to ACH. We've been using it
successfully since August 2005 - no modification - no issues, ever.
Our Accounting manager prints the payroll checks from Vantage on plain
white paper. When printing checks, Vantage asks for a location to save
the file. He saves the file then runs the vbscript which prompts for
the name of the file he just saved. The vbscript then prompts for the
name of the ACH file to output. It then creates an ACH file based on
the file from Vantage. My reason for vbscript - it is extremely small,
doesn't need a compiler and any Windows machine can run it.
I will try including my code in the body of this message: we'll see.
Just copy the code and paste it into a file called "ConvertToACH.vbs"
(name doesn't matter except for the .vbs portion). $2500 for something
that can be done with 355 lines of vbscript - give me a break!
Chris Gitzlaff
Major Industries
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fsoVantage, fVantage, fsoDD, fDD
Dim fileIn, fileOut
Function ACHAmount(Amount)
' This formats and returns a string representing the amount based on
ACH standards
' Ex. $420.15 in ACH format is 42015; $260 in ACH format is 26000
ACHAmount = CStr(Amount * 100)
End Function
Function ACHAmountOld(Amount)
' This formats and returns a string representing the amount based on
ACH standards
' Ex. $420.15 in ACH format is 42015; $260 in ACH format is 26000
Dim IntPortion, DecPortion, tmpDec, tmpAmount
IntPortion = Int(Amount)
DecPortion = Int((Amount - IntPortion) * 100) ' extract the decimal
portion
If DecPortion >= 10 Then
tmpDec = CStr(DecPortion)
Else
tmpDec = "0" & CStr(DecPortion)
End If
ACHAmountOld = CStr(IntPortion) & tmpDec
End Function
Function ACHDate(DateTime)
' This formats and returns a string representing the date based on
ACH standards (YYMMDD)
Dim tmpString
tmpString = Mid(Year(DateTime), 3, 2)
If Month(DateTime) < 10 Then
tmpString = tmpString & "0" & CStr(Month(DateTime))
Else
tmpString = tmpString & CStr(Month(DateTime))
End If
If Day(DateTime) < 10 Then
tmpString = tmpString & "0" & CStr(Day(DateTime))
Else
tmpString = tmpString & CStr(Day(DateTime))
End If
ACHDate = tmpString
End Function
Function ACHHash(TotalHash)
' The hash for each batch (record type 8) is created by adding the 8
digit bank routing
' number for each record in the batch.
' The hash for the file control record (record type 9) is created by
adding the hashes
' from each batch together
' The ACH format allows for a 10 digit entry hash. If the hash is
greater than 10
' digits, overflow out of the high order (left most portion is
ignored).
' Example: TotalHash = 11222333444; The hash used in the record
would be 1222333444
Dim tmpHash, tmpHashLength
tmpHash = CStr(TotalHash)
tmpHashLength = Len(tmpHash)
If tmpHashLength > 10 Then
ACHHash = Mid(tmpHash, (tmpHashLength - 10 + 1))
Else
ACHHash = tmpHash
End If
End Function
Function ACHTime(DateTime)
' This formats and returns a string representing the time based on
ACH standards (HHMM)
ACHTime = Replace(FormatDateTime(DateTime, 4), ":", "")
End Function
Function FileCreationDate(filespec)
' Given the name of a file, return the date and time it was created
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(filespec)
FileCreationDate = f.DateCreated
Set f = Nothing
Set fso = Nothing
End Function
Function SetStringToLength(DataString, FillChar, NewLength,
FillBeforeString)
' This function takes a data string and returns a string of the
specified "StringLength".
' If the string is longer than the specified string length, it
will shorten the string
' to match the specified length. If the string is shorter than
the specified length,
' this function will add a fill characters (FillChar) to make the
string the specified
' length. If FillBeforeString is true, any fill characters will
be added to the front of
' the string, otherwise they will be added to the end.
Dim DataStringLength
DataStringLength = Len(DataString)
Dim FillString
Dim i
If DataStringLength > NewLength Then ' cut the string and return it
SetStringToLength = Mid(DataString, 1, NewLength)
ElseIf DataStringLength = NewLength Then ' do nothing - return the
original string
SetStringToLength = DataString
Else ' Add fill characters to bring the string to the appropriate length
FillString = ""
For i = 1 To (NewLength - DataStringLength)
FillString = FillString & FillChar
Next
If FillBeforeString Then
SetStringToLength = FillString & DataString
Else
SetStringToLength = DataString & FillString
End If
End If
End Function
Set fsoVantage = CreateObject("Scripting.FileSystemObject")
Set fsoDD = CreateObject("Scripting.FileSystemObject")
fileIn = InputBox("Enter the name of the Source File. It must be in the
same directory as the conversion script." & vbCrLf & "Example:
TestDD7-20-01.txt", "Enter the Input File")
'If Not fsoVantage(fileIn).FileExists Then
' MsgBox "Error! File not found. Please enter a valid file name.
The file must be in the same directory as the conversion script."
' Exit Sub
'End If
Dim FileCreated
FileCreated = FileCreationDate(fileIn)
fileOut = InputBox("Enter the name of the Destination File.", "Enter the
Destination File", "MajorDD" & ACHDate(FileCreated) & ".ach")
'If fileOut = "" Then
' MsgBox "Error! Please enter a valid name for the converted ACH file."
' Exit Sub
'End If
' ***********************************************
' Read the data from the input file
' ***********************************************
Dim strInput
Set fVantage = fsoVantage.OpenTextFile(fileIn, ForReading)
strInput = fVantage.ReadAll
' The Vantage file has quotes around all text fields - remove quotes
strInput = Replace(strInput, Chr(34), "")
fVantage.Close
Set fVantage = Nothing
Set fsoVantage = Nothing
' Split the data into an array of records (one record per line)
Dim arrRecords, arrFields
arrRecords = Split(strInput, vbCrLf)
' Using zero as the base for the fields, these are the column locations
of the data needed
Dim intType, intFirst, intMid, intLast, intAmount, intDate, intBank,
intAccount
intType = 2
intFirst = 7
intMid = 8
intLast = 9
intAmount = 10
intDate = 11
intBank = 20
intAccount = 21
' read the first record to get the effective entry date of the
transaction (needed for the batch header)
arrFields = Split(arrRecords(0), ",")
Dim EffectiveEntryDate
EffectiveEntryDate = arrFields(intDate)
' ***********************************************
' ACH Constants
' ***********************************************
Const Bank_AccountNum = "07591161"
Const Bank_AccountCheckDigit = "6"
Const Bank_Name = "Peoples State Bank"
Const Company_Name = "Major Industries"
Const Company_BatchName = "Payroll"
Const Company_BatchNum = "1"
' (Tax ID: 493169, Federal ID: 39-1774642)
' The Federal Tax ID should be used. Remove any dashes - it becomes 9
digits
' When used, the company tax ID needs to be 10 digits - prefix with a
"1" (taken care of below)
Const Company_TaxID = "391774642"
' ***********************************************
' ACH header record 1 (line 1) Subsection 2.1.1 (OR41 top table)
' ***********************************************
strOutput = "1" ' (1) Record Type Code
strOutput = strOutput & "01" ' (2) Priority Code
strOutput = strOutput & " " & Bank_AccountNum & Bank_AccountCheckDigit '
(3) Immediate Destination
strOutput = strOutput & " " & Bank_AccountNum & Bank_AccountCheckDigit '
(4) Immediate Origin
strOutput = strOutput & ACHDate(FileCreated) ' (5) File Creation Date
strOutput = strOutput & ACHTime(FileCreated) ' (6) File Creation Time
strOutput = strOutput & "0" ' (7) File ID Modifier
strOutput = strOutput & "094" ' (8) Record Size
strOutput = strOutput & "10" ' (9) Blocking Factor
strOutput = strOutput & "1" ' (10) Format Code
strOutput = strOutput & SetStringToLength(Bank_Name, " ", 23, False) '
(11) Immediate Destination Name
strOutput = strOutput & SetStringToLength(Company_Name, " ", 23, False)
' (12) Immediate Origin Name; Bank or Company
strOutput = strOutput & SetStringToLength("", " ", 8, True) ' (13)
Reference Code; can be blank
strOutput = strOutput & vbCrLf ' Line is complete - move to the next line
' ***********************************************
' ACH header record 5 (line 2) Subsection 2.1.2 (OR42 top table)
' ***********************************************
strOutput = strOutput & "5" ' (1) Record Type Code
strOutput = strOutput & "200" ' (2) Service Class Code
strOutput = strOutput & SetStringToLength(Company_Name, " ", 16, False)
' (3) Company Name
strOutput = strOutput & SetStringToLength("", " ", 20, True) ' (4)
Company Discretionary Data
strOutput = strOutput & SetStringToLength("1" & Company_TaxID, " ", 10,
False) ' (5) Company Identification
strOutput = strOutput & "PPD" ' (6) Standard Entry Class Code
strOutput = strOutput & SetStringToLength(Company_BatchName, " ", 10,
False) ' (7) Company Entry Description
strOutput = strOutput & SetStringToLength("", " ", 6, True) ' (8)
Company Descriptive Date
strOutput = strOutput & ACHDate(EffectiveEntryDate) ' (9) Effective
Entry Date
strOutput = strOutput & SetStringToLength("", " ", 3, True) ' (10)
Settlement Date (Julian)
strOutput = strOutput & "1" ' (11) Originator Status Code
strOutput = strOutput & Bank_AccountNum ' (12) Originating DFI
Identification
strOutput = strOutput & SetStringToLength(Company_BatchNum, "0", 7,
True) ' (13) Batch Number
strOutput = strOutput & vbCrLf ' Line is complete - move to the next line
' ***********************************************
' ACH Individual records (lines 3-n) Subsection 2.1.4 (OR45 bottom table)
' ***********************************************
' Loop through each record and build the output string using the
appropriate fields
Dim i, j
Dim FullName, Count, tmpAmount, TotalAmount, Hash
Count = 0
TotalAmount = 0
Hash = 0
For i = 0 To UBound(arrRecords)
' Split each record into the individual fields
arrFields = Split(arrRecords(i), ",")
If UBound(arrFields) < 1 Then ' Eliminates any trailing lines from
the file
Exit For
End If
Count = Count + 1
tmpAmount = CSng(arrFields(intAmount))
' TotalAmount = TotalAmount + tmpAmount
TotalAmount = TotalAmount + CLng(ACHAmount(tmpAmount))
Hash = Hash + CDbl(arrFields(intBank))
strOutput = strOutput & "6" ' (1) Record Type Code
If arrFields(intType) = "DDCHK" Then ' Checking account
strOutput = strOutput & "22" ' (2) Transaction Code; 22 =
Checking, 32 = Savings
Else ' arrFields(intType) = "DDSAV" ' Savings account
strOutput = strOutput & "32" ' (2) Transaction Code; 22 =
Checking, 32 = Savings
End If
strOutput = strOutput & SetStringToLength(arrFields(intBank), " ",
9, False) ' (3) Receiving DFI Identification & (4) Check Digit
' ** Begin layout according to 2004 / 2005 operating rules
'strOutput = strOutput & SetStringToLength(arrFields(intAccount), "
", 15, False) ' (5) DFI Account Number
'strOutput = strOutput & SetStringToLength(ACHAmount(tmpAmount),
"0", 12, True) ' (6) Amount
' ** End layout according to 2004 / 2005 operating rules
' ** Begin layout modification - PSB
strOutput = strOutput & SetStringToLength(arrFields(intAccount), "
", 17, False) ' (5) DFI Account Number
strOutput = strOutput & SetStringToLength(ACHAmount(tmpAmount), "0",
10, True) ' (6) Amount
' ** End layout modification - PSB
' strOutput = strOutput & SetStringToLength(0, "0", 12, True) ' (6)
Amount (for testing accounts - substitute real amounts with $0
strOutput = strOutput & SetStringToLength("", " ", 9, True) ' (7)
Advice Routing Number
strOutput = strOutput & SetStringToLength("", " ", 5, True) ' (8)
File Identification
strOutput = strOutput & SetStringToLength("", " ", 1, True) ' (9)
ACH Operator Data
FullName = Trim(arrFields(intLast) & ", " & arrFields(intFirst) & "
" & arrFields(intMid))
strOutput = strOutput & SetStringToLength(FullName, " ", 22, False)
' (10) Individual Name
strOutput = strOutput & SetStringToLength("", " ", 2, True) ' (11)
Discretionary Data
strOutput = strOutput & "0" ' (12) Addenda Record Indicator
strOutput = strOutput & Bank_AccountNum ' (13) Routing Number of ACH
Operator
strOutput = strOutput & SetStringToLength("", "0", 3, True) ' (14)
Julian Date On Which This Advice Is Created
strOutput = strOutput & SetStringToLength(CStr(Count), "0", 4, True)
' (15) Sequence Number Within Batch
strOutput = strOutput & vbCrLf ' Line is complete - move to the next
line
Set arrFields = Nothing
Next
' ***********************************************
' ACH footer record 8 Subsection 2.1.2 (OR42 bottom table)
' ***********************************************
strOutput = strOutput & "8" ' (1) Record Type Code
strOutput = strOutput & "200" ' (2) Service Class Code
strOutput = strOutput & SetStringToLength(CStr(Count), "0", 6, True) '
(3) Entry / Addenda Count
strOutput = strOutput & SetStringToLength(ACHHash(Hash), "0", 10, True)
' (4) Entry Hash
strOutput = strOutput & SetStringToLength(0, "0", 12, True) ' (5) Total
Debit Entry Dollar Amount
'strOutput = strOutput & SetStringToLength(ACHAmount(TotalAmount), "0",
12, True) ' (6) Total Credit Entry Dollar Amount
strOutput = strOutput & SetStringToLength(CStr(TotalAmount), "0", 12,
True) ' (6) Total Credit Entry Dollar Amount
strOutput = strOutput & SetStringToLength("1" & Company_TaxID, " ", 10,
False) ' (7) Company Identification
strOutput = strOutput & SetStringToLength("", " ", 19, True) ' (8)
Message Authentication Code
strOutput = strOutput & SetStringToLength("", " ", 6, True) ' (9) Reserved
strOutput = strOutput & Bank_AccountNum ' (10) Originating DFI
Identification
strOutput = strOutput & SetStringToLength(Company_BatchNum, "0", 7,
True) ' (11) Batch Number
strOutput = strOutput & vbCrLf ' Line is complete - move to the next line
' ***********************************************
' ACH block count / End of File line count
' ***********************************************
' ?? Peoples State Bank recommended a minimum of 3 rows of 94 9's ; Have
seen as many as 8 rows ??
' 1 block = 940 characters = 10 lines in ACH file (without Cr and Lf)
' Lines:
' 1 for the file header (record type 1)
' 1 for the file control record (record type 9)
' 1 for each batch header record (record type 5)
' 1 for each batch control record (record type 8)
' x for each individual record (record type 6)
' y determine the number of end of file lines to create a full block
Dim Lines, EOFLines, BlockCount
Lines = 4 + Count
If (Lines Mod 10) > 0 Then
EOFLines = 10 - (Lines Mod 10)
Else
EOFLines = 0
End If
BlockCount = Int(Lines / 10)
If EOFLines > 0 Then
BlockCount = BlockCount + 1
End If
' ***********************************************
' ACH footer record 9 Subsection 2.1.1 (OR41 bottom table)
' ***********************************************
strOutput = strOutput & "9" ' (1) Record Type Code
strOutput = strOutput & SetStringToLength(1, "0", 6, True) ' (2) Batch Count
strOutput = strOutput & SetStringToLength(BlockCount, "0", 6, True) '
(3) Block Count
strOutput = strOutput & SetStringToLength(CStr(Count), "0", 8, True) '
(4) Entry / Addenda Count
strOutput = strOutput & SetStringToLength(ACHHash(Hash), "0", 10, True)
' (5) Entry Hash
strOutput = strOutput & SetStringToLength(0, "0", 12, True) ' (6) Total
Debit Entry Dollar Amount in File
'strOutput = strOutput & SetStringToLength(ACHAmount(TotalAmount), "0",
12, True) ' (7) Total Credit Entry Dollar Amount in File
strOutput = strOutput & SetStringToLength(CStr(TotalAmount), "0", 12,
True) ' (7) Total Credit Entry Dollar Amount in File
strOutput = strOutput & SetStringToLength("", " ", 39, True) ' (8) Reserved
strOutput = strOutput & vbCrLf ' Line is complete - move to the next line
' ***********************************************
' ACH End of File
' ***********************************************
For i = 1 To EOFLines
strOutput = strOutput & SetStringToLength("", "9", 94, True)
strOutput = strOutput & vbCrLf ' End of line
Next
' ***********************************************
' Write the output string (strOutput) to the output file (fileOut)
' ***********************************************
Set fDD = fsoDD.OpenTextFile(fileOut, ForWriting, True)
fDD.Write strOutput
fDD.Close
Set fDD = Nothing
Set fsoDD = Nothing
My bank provided me with the specs for the ACH files. I wrote a program
(vbscript) to convert Vantage output to ACH. We've been using it
successfully since August 2005 - no modification - no issues, ever.
Our Accounting manager prints the payroll checks from Vantage on plain
white paper. When printing checks, Vantage asks for a location to save
the file. He saves the file then runs the vbscript which prompts for
the name of the file he just saved. The vbscript then prompts for the
name of the ACH file to output. It then creates an ACH file based on
the file from Vantage. My reason for vbscript - it is extremely small,
doesn't need a compiler and any Windows machine can run it.
I will try including my code in the body of this message: we'll see.
Just copy the code and paste it into a file called "ConvertToACH.vbs"
(name doesn't matter except for the .vbs portion). $2500 for something
that can be done with 355 lines of vbscript - give me a break!
Chris Gitzlaff
Major Industries
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fsoVantage, fVantage, fsoDD, fDD
Dim fileIn, fileOut
Function ACHAmount(Amount)
' This formats and returns a string representing the amount based on
ACH standards
' Ex. $420.15 in ACH format is 42015; $260 in ACH format is 26000
ACHAmount = CStr(Amount * 100)
End Function
Function ACHAmountOld(Amount)
' This formats and returns a string representing the amount based on
ACH standards
' Ex. $420.15 in ACH format is 42015; $260 in ACH format is 26000
Dim IntPortion, DecPortion, tmpDec, tmpAmount
IntPortion = Int(Amount)
DecPortion = Int((Amount - IntPortion) * 100) ' extract the decimal
portion
If DecPortion >= 10 Then
tmpDec = CStr(DecPortion)
Else
tmpDec = "0" & CStr(DecPortion)
End If
ACHAmountOld = CStr(IntPortion) & tmpDec
End Function
Function ACHDate(DateTime)
' This formats and returns a string representing the date based on
ACH standards (YYMMDD)
Dim tmpString
tmpString = Mid(Year(DateTime), 3, 2)
If Month(DateTime) < 10 Then
tmpString = tmpString & "0" & CStr(Month(DateTime))
Else
tmpString = tmpString & CStr(Month(DateTime))
End If
If Day(DateTime) < 10 Then
tmpString = tmpString & "0" & CStr(Day(DateTime))
Else
tmpString = tmpString & CStr(Day(DateTime))
End If
ACHDate = tmpString
End Function
Function ACHHash(TotalHash)
' The hash for each batch (record type 8) is created by adding the 8
digit bank routing
' number for each record in the batch.
' The hash for the file control record (record type 9) is created by
adding the hashes
' from each batch together
' The ACH format allows for a 10 digit entry hash. If the hash is
greater than 10
' digits, overflow out of the high order (left most portion is
ignored).
' Example: TotalHash = 11222333444; The hash used in the record
would be 1222333444
Dim tmpHash, tmpHashLength
tmpHash = CStr(TotalHash)
tmpHashLength = Len(tmpHash)
If tmpHashLength > 10 Then
ACHHash = Mid(tmpHash, (tmpHashLength - 10 + 1))
Else
ACHHash = tmpHash
End If
End Function
Function ACHTime(DateTime)
' This formats and returns a string representing the time based on
ACH standards (HHMM)
ACHTime = Replace(FormatDateTime(DateTime, 4), ":", "")
End Function
Function FileCreationDate(filespec)
' Given the name of a file, return the date and time it was created
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(filespec)
FileCreationDate = f.DateCreated
Set f = Nothing
Set fso = Nothing
End Function
Function SetStringToLength(DataString, FillChar, NewLength,
FillBeforeString)
' This function takes a data string and returns a string of the
specified "StringLength".
' If the string is longer than the specified string length, it
will shorten the string
' to match the specified length. If the string is shorter than
the specified length,
' this function will add a fill characters (FillChar) to make the
string the specified
' length. If FillBeforeString is true, any fill characters will
be added to the front of
' the string, otherwise they will be added to the end.
Dim DataStringLength
DataStringLength = Len(DataString)
Dim FillString
Dim i
If DataStringLength > NewLength Then ' cut the string and return it
SetStringToLength = Mid(DataString, 1, NewLength)
ElseIf DataStringLength = NewLength Then ' do nothing - return the
original string
SetStringToLength = DataString
Else ' Add fill characters to bring the string to the appropriate length
FillString = ""
For i = 1 To (NewLength - DataStringLength)
FillString = FillString & FillChar
Next
If FillBeforeString Then
SetStringToLength = FillString & DataString
Else
SetStringToLength = DataString & FillString
End If
End If
End Function
Set fsoVantage = CreateObject("Scripting.FileSystemObject")
Set fsoDD = CreateObject("Scripting.FileSystemObject")
fileIn = InputBox("Enter the name of the Source File. It must be in the
same directory as the conversion script." & vbCrLf & "Example:
TestDD7-20-01.txt", "Enter the Input File")
'If Not fsoVantage(fileIn).FileExists Then
' MsgBox "Error! File not found. Please enter a valid file name.
The file must be in the same directory as the conversion script."
' Exit Sub
'End If
Dim FileCreated
FileCreated = FileCreationDate(fileIn)
fileOut = InputBox("Enter the name of the Destination File.", "Enter the
Destination File", "MajorDD" & ACHDate(FileCreated) & ".ach")
'If fileOut = "" Then
' MsgBox "Error! Please enter a valid name for the converted ACH file."
' Exit Sub
'End If
' ***********************************************
' Read the data from the input file
' ***********************************************
Dim strInput
Set fVantage = fsoVantage.OpenTextFile(fileIn, ForReading)
strInput = fVantage.ReadAll
' The Vantage file has quotes around all text fields - remove quotes
strInput = Replace(strInput, Chr(34), "")
fVantage.Close
Set fVantage = Nothing
Set fsoVantage = Nothing
' Split the data into an array of records (one record per line)
Dim arrRecords, arrFields
arrRecords = Split(strInput, vbCrLf)
' Using zero as the base for the fields, these are the column locations
of the data needed
Dim intType, intFirst, intMid, intLast, intAmount, intDate, intBank,
intAccount
intType = 2
intFirst = 7
intMid = 8
intLast = 9
intAmount = 10
intDate = 11
intBank = 20
intAccount = 21
' read the first record to get the effective entry date of the
transaction (needed for the batch header)
arrFields = Split(arrRecords(0), ",")
Dim EffectiveEntryDate
EffectiveEntryDate = arrFields(intDate)
' ***********************************************
' ACH Constants
' ***********************************************
Const Bank_AccountNum = "07591161"
Const Bank_AccountCheckDigit = "6"
Const Bank_Name = "Peoples State Bank"
Const Company_Name = "Major Industries"
Const Company_BatchName = "Payroll"
Const Company_BatchNum = "1"
' (Tax ID: 493169, Federal ID: 39-1774642)
' The Federal Tax ID should be used. Remove any dashes - it becomes 9
digits
' When used, the company tax ID needs to be 10 digits - prefix with a
"1" (taken care of below)
Const Company_TaxID = "391774642"
' ***********************************************
' ACH header record 1 (line 1) Subsection 2.1.1 (OR41 top table)
' ***********************************************
strOutput = "1" ' (1) Record Type Code
strOutput = strOutput & "01" ' (2) Priority Code
strOutput = strOutput & " " & Bank_AccountNum & Bank_AccountCheckDigit '
(3) Immediate Destination
strOutput = strOutput & " " & Bank_AccountNum & Bank_AccountCheckDigit '
(4) Immediate Origin
strOutput = strOutput & ACHDate(FileCreated) ' (5) File Creation Date
strOutput = strOutput & ACHTime(FileCreated) ' (6) File Creation Time
strOutput = strOutput & "0" ' (7) File ID Modifier
strOutput = strOutput & "094" ' (8) Record Size
strOutput = strOutput & "10" ' (9) Blocking Factor
strOutput = strOutput & "1" ' (10) Format Code
strOutput = strOutput & SetStringToLength(Bank_Name, " ", 23, False) '
(11) Immediate Destination Name
strOutput = strOutput & SetStringToLength(Company_Name, " ", 23, False)
' (12) Immediate Origin Name; Bank or Company
strOutput = strOutput & SetStringToLength("", " ", 8, True) ' (13)
Reference Code; can be blank
strOutput = strOutput & vbCrLf ' Line is complete - move to the next line
' ***********************************************
' ACH header record 5 (line 2) Subsection 2.1.2 (OR42 top table)
' ***********************************************
strOutput = strOutput & "5" ' (1) Record Type Code
strOutput = strOutput & "200" ' (2) Service Class Code
strOutput = strOutput & SetStringToLength(Company_Name, " ", 16, False)
' (3) Company Name
strOutput = strOutput & SetStringToLength("", " ", 20, True) ' (4)
Company Discretionary Data
strOutput = strOutput & SetStringToLength("1" & Company_TaxID, " ", 10,
False) ' (5) Company Identification
strOutput = strOutput & "PPD" ' (6) Standard Entry Class Code
strOutput = strOutput & SetStringToLength(Company_BatchName, " ", 10,
False) ' (7) Company Entry Description
strOutput = strOutput & SetStringToLength("", " ", 6, True) ' (8)
Company Descriptive Date
strOutput = strOutput & ACHDate(EffectiveEntryDate) ' (9) Effective
Entry Date
strOutput = strOutput & SetStringToLength("", " ", 3, True) ' (10)
Settlement Date (Julian)
strOutput = strOutput & "1" ' (11) Originator Status Code
strOutput = strOutput & Bank_AccountNum ' (12) Originating DFI
Identification
strOutput = strOutput & SetStringToLength(Company_BatchNum, "0", 7,
True) ' (13) Batch Number
strOutput = strOutput & vbCrLf ' Line is complete - move to the next line
' ***********************************************
' ACH Individual records (lines 3-n) Subsection 2.1.4 (OR45 bottom table)
' ***********************************************
' Loop through each record and build the output string using the
appropriate fields
Dim i, j
Dim FullName, Count, tmpAmount, TotalAmount, Hash
Count = 0
TotalAmount = 0
Hash = 0
For i = 0 To UBound(arrRecords)
' Split each record into the individual fields
arrFields = Split(arrRecords(i), ",")
If UBound(arrFields) < 1 Then ' Eliminates any trailing lines from
the file
Exit For
End If
Count = Count + 1
tmpAmount = CSng(arrFields(intAmount))
' TotalAmount = TotalAmount + tmpAmount
TotalAmount = TotalAmount + CLng(ACHAmount(tmpAmount))
Hash = Hash + CDbl(arrFields(intBank))
strOutput = strOutput & "6" ' (1) Record Type Code
If arrFields(intType) = "DDCHK" Then ' Checking account
strOutput = strOutput & "22" ' (2) Transaction Code; 22 =
Checking, 32 = Savings
Else ' arrFields(intType) = "DDSAV" ' Savings account
strOutput = strOutput & "32" ' (2) Transaction Code; 22 =
Checking, 32 = Savings
End If
strOutput = strOutput & SetStringToLength(arrFields(intBank), " ",
9, False) ' (3) Receiving DFI Identification & (4) Check Digit
' ** Begin layout according to 2004 / 2005 operating rules
'strOutput = strOutput & SetStringToLength(arrFields(intAccount), "
", 15, False) ' (5) DFI Account Number
'strOutput = strOutput & SetStringToLength(ACHAmount(tmpAmount),
"0", 12, True) ' (6) Amount
' ** End layout according to 2004 / 2005 operating rules
' ** Begin layout modification - PSB
strOutput = strOutput & SetStringToLength(arrFields(intAccount), "
", 17, False) ' (5) DFI Account Number
strOutput = strOutput & SetStringToLength(ACHAmount(tmpAmount), "0",
10, True) ' (6) Amount
' ** End layout modification - PSB
' strOutput = strOutput & SetStringToLength(0, "0", 12, True) ' (6)
Amount (for testing accounts - substitute real amounts with $0
strOutput = strOutput & SetStringToLength("", " ", 9, True) ' (7)
Advice Routing Number
strOutput = strOutput & SetStringToLength("", " ", 5, True) ' (8)
File Identification
strOutput = strOutput & SetStringToLength("", " ", 1, True) ' (9)
ACH Operator Data
FullName = Trim(arrFields(intLast) & ", " & arrFields(intFirst) & "
" & arrFields(intMid))
strOutput = strOutput & SetStringToLength(FullName, " ", 22, False)
' (10) Individual Name
strOutput = strOutput & SetStringToLength("", " ", 2, True) ' (11)
Discretionary Data
strOutput = strOutput & "0" ' (12) Addenda Record Indicator
strOutput = strOutput & Bank_AccountNum ' (13) Routing Number of ACH
Operator
strOutput = strOutput & SetStringToLength("", "0", 3, True) ' (14)
Julian Date On Which This Advice Is Created
strOutput = strOutput & SetStringToLength(CStr(Count), "0", 4, True)
' (15) Sequence Number Within Batch
strOutput = strOutput & vbCrLf ' Line is complete - move to the next
line
Set arrFields = Nothing
Next
' ***********************************************
' ACH footer record 8 Subsection 2.1.2 (OR42 bottom table)
' ***********************************************
strOutput = strOutput & "8" ' (1) Record Type Code
strOutput = strOutput & "200" ' (2) Service Class Code
strOutput = strOutput & SetStringToLength(CStr(Count), "0", 6, True) '
(3) Entry / Addenda Count
strOutput = strOutput & SetStringToLength(ACHHash(Hash), "0", 10, True)
' (4) Entry Hash
strOutput = strOutput & SetStringToLength(0, "0", 12, True) ' (5) Total
Debit Entry Dollar Amount
'strOutput = strOutput & SetStringToLength(ACHAmount(TotalAmount), "0",
12, True) ' (6) Total Credit Entry Dollar Amount
strOutput = strOutput & SetStringToLength(CStr(TotalAmount), "0", 12,
True) ' (6) Total Credit Entry Dollar Amount
strOutput = strOutput & SetStringToLength("1" & Company_TaxID, " ", 10,
False) ' (7) Company Identification
strOutput = strOutput & SetStringToLength("", " ", 19, True) ' (8)
Message Authentication Code
strOutput = strOutput & SetStringToLength("", " ", 6, True) ' (9) Reserved
strOutput = strOutput & Bank_AccountNum ' (10) Originating DFI
Identification
strOutput = strOutput & SetStringToLength(Company_BatchNum, "0", 7,
True) ' (11) Batch Number
strOutput = strOutput & vbCrLf ' Line is complete - move to the next line
' ***********************************************
' ACH block count / End of File line count
' ***********************************************
' ?? Peoples State Bank recommended a minimum of 3 rows of 94 9's ; Have
seen as many as 8 rows ??
' 1 block = 940 characters = 10 lines in ACH file (without Cr and Lf)
' Lines:
' 1 for the file header (record type 1)
' 1 for the file control record (record type 9)
' 1 for each batch header record (record type 5)
' 1 for each batch control record (record type 8)
' x for each individual record (record type 6)
' y determine the number of end of file lines to create a full block
Dim Lines, EOFLines, BlockCount
Lines = 4 + Count
If (Lines Mod 10) > 0 Then
EOFLines = 10 - (Lines Mod 10)
Else
EOFLines = 0
End If
BlockCount = Int(Lines / 10)
If EOFLines > 0 Then
BlockCount = BlockCount + 1
End If
' ***********************************************
' ACH footer record 9 Subsection 2.1.1 (OR41 bottom table)
' ***********************************************
strOutput = strOutput & "9" ' (1) Record Type Code
strOutput = strOutput & SetStringToLength(1, "0", 6, True) ' (2) Batch Count
strOutput = strOutput & SetStringToLength(BlockCount, "0", 6, True) '
(3) Block Count
strOutput = strOutput & SetStringToLength(CStr(Count), "0", 8, True) '
(4) Entry / Addenda Count
strOutput = strOutput & SetStringToLength(ACHHash(Hash), "0", 10, True)
' (5) Entry Hash
strOutput = strOutput & SetStringToLength(0, "0", 12, True) ' (6) Total
Debit Entry Dollar Amount in File
'strOutput = strOutput & SetStringToLength(ACHAmount(TotalAmount), "0",
12, True) ' (7) Total Credit Entry Dollar Amount in File
strOutput = strOutput & SetStringToLength(CStr(TotalAmount), "0", 12,
True) ' (7) Total Credit Entry Dollar Amount in File
strOutput = strOutput & SetStringToLength("", " ", 39, True) ' (8) Reserved
strOutput = strOutput & vbCrLf ' Line is complete - move to the next line
' ***********************************************
' ACH End of File
' ***********************************************
For i = 1 To EOFLines
strOutput = strOutput & SetStringToLength("", "9", 94, True)
strOutput = strOutput & vbCrLf ' End of line
Next
' ***********************************************
' Write the output string (strOutput) to the output file (fileOut)
' ***********************************************
Set fDD = fsoDD.OpenTextFile(fileOut, ForWriting, True)
fDD.Write strOutput
fDD.Close
Set fDD = Nothing
Set fsoDD = Nothing