badmotorvision
Programmer
I am attempting to create PO's via a VB.NET interface that I have written. The only problem I am having is that the
line # in the PO Lines is being ignored. This is was happens
Lets say I have 2 lines on the PO. When I add line 1
I set POPOR1detail1Fields.FieldByName("PORLREV").PutWithoutVerification(lineNumber)
and
POPOR1detail1Fields.FieldByName("PORLSEQ").PutWithoutVerification(lineNumber)
LineNumber represents the actual line # IE 1 multiplied by 1000 so line 1 is 1000 line 2 is 2000 etc.
After the interface runs I find that the first item added IE
line 1 has become line 2 and the second line line 2 has become line 1. TOtally ignoring the line #'s that I set. The only way around this is to insert the lines in reverse order so they match accourdinly in ACCPAC.
I am pasting the actual code so you can see what im talking about.
Begin Code
For Each r As WEB_POR_Detail.POR_DetailRow In aLines
Dim ls_Exp, ls_Fac, ls_Service As String
Dim ls_FullGL As String
ls_FullGL = r.txt_GL_Account
ls_Exp = Left(ls_FullGL, 4)
'ls_Fac = ls_FullGL.Substring(4, 3)
ls_Fac = aHeader.txt_GL_Account
'ls_Service = ls_FullGL.Substring(7, 1)
ls_Service = ls_Exp.Substring(3, 1)
'ls_State = ls_FullGL.Substring(8, 2)
Dim ls_PartNumber As String = ""
If r.int_Line_Number = 1 Then
'Add PO Comments
End If
Try
If r.tf_ExchangeRequired Then
End If
Catch ex As Exception
End Try
Dim segment As String = aHeader.txt_mfr_model_segment.Trim
segment += "-" + r.txt_Item_Number.Trim
segment = Left(segment, 24)
''''''''''''''''
Select Case ls_Exp
Case "5100", "5101"
ls_PartNumber = segment
Case "4200", "4201"
ls_PartNumber = segment
Case "5200", "5201"
ls_PartNumber = r.txt_Item_Number
Case "5250", "5251"
ls_PartNumber = r.txt_Item_Number
Case "5540", "5541" ' Supplies
ls_PartNumber = r.txt_Item_Number
Case "5550", "5551"
ls_PartNumber = r.txt_Item_Number
Case "5300", "5301"
'Segment contract site 4 pass/reg R desc 10
ls_PartNumber = ls_Fac + "R" + Left(r.txt_Item_Description, 10)
Case "5400", "5401"
ls_PartNumber = ls_Fac + "P" + Left(r.txt_Item_Description, 10)
Case "5160", "5161" ' Core exchange
ls_PartNumber = r.txt_Item_Number
Case "5830"
ls_PartNumber = ls_Fac + "0" + Left(r.txt_Item_Description, 10)
Case "5831"
ls_PartNumber = ls_Fac + "1" + Left(r.txt_Item_Description, 10)
Case "5832"
ls_PartNumber = ls_Fac + "2" + Left(r.txt_Item_Description, 10)
Case "5833"
ls_PartNumber = ls_Fac + "3" + Left(r.txt_Item_Description, 10)
Case "5834"
ls_PartNumber = ls_Fac + "4" + Left(r.txt_Item_Description, 10)
Case "5835"
ls_PartNumber = ls_Fac + "5" + Left(r.txt_Item_Description, 10)
End Select
Dim tf_Delete As Boolean = False
Try
tf_Delete = r.tf_deleteLine
Catch ex As Exception
tf_Delete = False
End Try
Dim ld_qty, ld_Cost As Decimal
ld_qty = r.dec_QTY
ld_Cost = r.dec_Unit_Price
If tf_Delete Then
ld_qty = 0
ld_Cost = 0
tf_Delete = False
End If
If Not tf_Delete Then
Try
'COMPLETION
If ld_qty = 0 And ld_Cost = 0 Then
Try
'POPOR1detail1Fields.FieldByName("COMPLETION").Value = 1
'ISCOMPLETE
POPOR1detail1Fields.FieldByName("ISCOMPLETE").Value = 1
Catch ex As Exception
End Try
Try
POPOR1detail1Fields.FieldByName("DTCOMPLETE").Value = DateTime.Now
Catch ex As Exception
End Try
'DTCOMPLETE
End If
temp = POPOR1detail1.Exists
POPOR1detail1.RecordClear()
temp = POPOR1detail1.Exists
POPOR1detail1.RecordCreate(0)
Dim lineNumber As Integer
lineNumber = r.int_Line_Number * 1000
Try
Me._SysError("Item NUMBER " + ls_PartNumber + " Line # " + lineNumber.ToString, False)
Catch ex As Exception
End Try
POPOR1detail1Fields.FieldByName("PORLREV").PutWithoutVerification(lineNumber)
POPOR1detail1Fields.FieldByName("PORLSEQ").PutWithoutVerification(lineNumber)
Dim m_part As String
m_part = r.txt_Item_Number
'All items need to be verified
_VerifyInventoryItem(segment, r.txt_Item_Description, aHeader, r)
POPOR1detail1Fields.FieldByName("ITEMNO").Value = ls_PartNumber
Try
POPOR1detail1Fields.FieldByName("ITEMDESC").Value = r.txt_Item_Description ' Item Description
Catch ex As Exception
Me._SysError("Exception in _CreatePO", True)
End Try
Try
POPOR1detail1Fields.FieldByName("OQORDERED").Value = ld_qty ' Quantity Ordered
Catch ex As Exception
Me._SysError("Exception in _CreatePO", True)
End Try
Try
POPOR1detail1Fields.FieldByName("UNITCOST").Value = ld_Cost ' Unit Cost
Catch ex As Exception
Me._SysError("Exception in _CreatePO", True)
End Try
Dim fmt As String
'5100-2081-02
'Accpac wont allow expense code entry on po line on inventory items
' only on items that are not in inventory.
Try
POPOR1detail1Fields.FieldByName("LOCATION").Value = aHeader.txt_GL_Account ' Location
Catch ex As Exception
End Try
If li_CommentLines > 0 Then
If r.int_Line_Number = 1 Then
POPOR1detail1Fields.FieldByName("HASCOMMENT").Value = "1" ' Comments/Instructions
POPOR1detail2.RecordClear()
POPOR1detail2.RecordCreate(0)
POPOR1detail2Fields.FieldByName("COMMENT").PutWithoutVerification(aHeader.txt_Description) ' Comments/Instructions
POPOR1detail2.Insert()
End If
End If
If r.tf_ExchangeRequired Then
Dim ls_RTN As String = ""
Try
ls_RTN = r.txt_Return_Comments
Catch ex As Exception
ls_RTN = ""
End Try
If ls_RTN.Length > 0 Then
POPOR1detail1Fields.FieldByName("HASCOMMENT").Value = "1" ' Comments/Instructions
POPOR1detail2.RecordClear()
POPOR1detail2.RecordCreate(0)
POPOR1detail2Fields.FieldByName("COMMENT").PutWithoutVerification(ls_RTN) ' Comments/Instructions
POPOR1detail2.Insert()
End If
End If
POPOR1detail1.Insert()
'_VerifyInventoryItem(segment, r.txt_Item_Description, aHeader, r)
Catch ex As Exception
Me._SysError("Exception in _CreatePO", True)
aHeader.txt_ActionRequired = "2ACCPAC"
End Try
End If
Next
POPOR1detail1Fields.FieldByName("PORLREV").PutWithoutVerification("-1") ' Line Number
POPOR1detail1.Read()
POPOR1detail4Fields.FieldByName("FUNCTION").PutWithoutVerification("8") ' Function
line # in the PO Lines is being ignored. This is was happens
Lets say I have 2 lines on the PO. When I add line 1
I set POPOR1detail1Fields.FieldByName("PORLREV").PutWithoutVerification(lineNumber)
and
POPOR1detail1Fields.FieldByName("PORLSEQ").PutWithoutVerification(lineNumber)
LineNumber represents the actual line # IE 1 multiplied by 1000 so line 1 is 1000 line 2 is 2000 etc.
After the interface runs I find that the first item added IE
line 1 has become line 2 and the second line line 2 has become line 1. TOtally ignoring the line #'s that I set. The only way around this is to insert the lines in reverse order so they match accourdinly in ACCPAC.
I am pasting the actual code so you can see what im talking about.
Begin Code
For Each r As WEB_POR_Detail.POR_DetailRow In aLines
Dim ls_Exp, ls_Fac, ls_Service As String
Dim ls_FullGL As String
ls_FullGL = r.txt_GL_Account
ls_Exp = Left(ls_FullGL, 4)
'ls_Fac = ls_FullGL.Substring(4, 3)
ls_Fac = aHeader.txt_GL_Account
'ls_Service = ls_FullGL.Substring(7, 1)
ls_Service = ls_Exp.Substring(3, 1)
'ls_State = ls_FullGL.Substring(8, 2)
Dim ls_PartNumber As String = ""
If r.int_Line_Number = 1 Then
'Add PO Comments
End If
Try
If r.tf_ExchangeRequired Then
End If
Catch ex As Exception
End Try
Dim segment As String = aHeader.txt_mfr_model_segment.Trim
segment += "-" + r.txt_Item_Number.Trim
segment = Left(segment, 24)
''''''''''''''''
Select Case ls_Exp
Case "5100", "5101"
ls_PartNumber = segment
Case "4200", "4201"
ls_PartNumber = segment
Case "5200", "5201"
ls_PartNumber = r.txt_Item_Number
Case "5250", "5251"
ls_PartNumber = r.txt_Item_Number
Case "5540", "5541" ' Supplies
ls_PartNumber = r.txt_Item_Number
Case "5550", "5551"
ls_PartNumber = r.txt_Item_Number
Case "5300", "5301"
'Segment contract site 4 pass/reg R desc 10
ls_PartNumber = ls_Fac + "R" + Left(r.txt_Item_Description, 10)
Case "5400", "5401"
ls_PartNumber = ls_Fac + "P" + Left(r.txt_Item_Description, 10)
Case "5160", "5161" ' Core exchange
ls_PartNumber = r.txt_Item_Number
Case "5830"
ls_PartNumber = ls_Fac + "0" + Left(r.txt_Item_Description, 10)
Case "5831"
ls_PartNumber = ls_Fac + "1" + Left(r.txt_Item_Description, 10)
Case "5832"
ls_PartNumber = ls_Fac + "2" + Left(r.txt_Item_Description, 10)
Case "5833"
ls_PartNumber = ls_Fac + "3" + Left(r.txt_Item_Description, 10)
Case "5834"
ls_PartNumber = ls_Fac + "4" + Left(r.txt_Item_Description, 10)
Case "5835"
ls_PartNumber = ls_Fac + "5" + Left(r.txt_Item_Description, 10)
End Select
Dim tf_Delete As Boolean = False
Try
tf_Delete = r.tf_deleteLine
Catch ex As Exception
tf_Delete = False
End Try
Dim ld_qty, ld_Cost As Decimal
ld_qty = r.dec_QTY
ld_Cost = r.dec_Unit_Price
If tf_Delete Then
ld_qty = 0
ld_Cost = 0
tf_Delete = False
End If
If Not tf_Delete Then
Try
'COMPLETION
If ld_qty = 0 And ld_Cost = 0 Then
Try
'POPOR1detail1Fields.FieldByName("COMPLETION").Value = 1
'ISCOMPLETE
POPOR1detail1Fields.FieldByName("ISCOMPLETE").Value = 1
Catch ex As Exception
End Try
Try
POPOR1detail1Fields.FieldByName("DTCOMPLETE").Value = DateTime.Now
Catch ex As Exception
End Try
'DTCOMPLETE
End If
temp = POPOR1detail1.Exists
POPOR1detail1.RecordClear()
temp = POPOR1detail1.Exists
POPOR1detail1.RecordCreate(0)
Dim lineNumber As Integer
lineNumber = r.int_Line_Number * 1000
Try
Me._SysError("Item NUMBER " + ls_PartNumber + " Line # " + lineNumber.ToString, False)
Catch ex As Exception
End Try
POPOR1detail1Fields.FieldByName("PORLREV").PutWithoutVerification(lineNumber)
POPOR1detail1Fields.FieldByName("PORLSEQ").PutWithoutVerification(lineNumber)
Dim m_part As String
m_part = r.txt_Item_Number
'All items need to be verified
_VerifyInventoryItem(segment, r.txt_Item_Description, aHeader, r)
POPOR1detail1Fields.FieldByName("ITEMNO").Value = ls_PartNumber
Try
POPOR1detail1Fields.FieldByName("ITEMDESC").Value = r.txt_Item_Description ' Item Description
Catch ex As Exception
Me._SysError("Exception in _CreatePO", True)
End Try
Try
POPOR1detail1Fields.FieldByName("OQORDERED").Value = ld_qty ' Quantity Ordered
Catch ex As Exception
Me._SysError("Exception in _CreatePO", True)
End Try
Try
POPOR1detail1Fields.FieldByName("UNITCOST").Value = ld_Cost ' Unit Cost
Catch ex As Exception
Me._SysError("Exception in _CreatePO", True)
End Try
Dim fmt As String
'5100-2081-02
'Accpac wont allow expense code entry on po line on inventory items
' only on items that are not in inventory.
Try
POPOR1detail1Fields.FieldByName("LOCATION").Value = aHeader.txt_GL_Account ' Location
Catch ex As Exception
End Try
If li_CommentLines > 0 Then
If r.int_Line_Number = 1 Then
POPOR1detail1Fields.FieldByName("HASCOMMENT").Value = "1" ' Comments/Instructions
POPOR1detail2.RecordClear()
POPOR1detail2.RecordCreate(0)
POPOR1detail2Fields.FieldByName("COMMENT").PutWithoutVerification(aHeader.txt_Description) ' Comments/Instructions
POPOR1detail2.Insert()
End If
End If
If r.tf_ExchangeRequired Then
Dim ls_RTN As String = ""
Try
ls_RTN = r.txt_Return_Comments
Catch ex As Exception
ls_RTN = ""
End Try
If ls_RTN.Length > 0 Then
POPOR1detail1Fields.FieldByName("HASCOMMENT").Value = "1" ' Comments/Instructions
POPOR1detail2.RecordClear()
POPOR1detail2.RecordCreate(0)
POPOR1detail2Fields.FieldByName("COMMENT").PutWithoutVerification(ls_RTN) ' Comments/Instructions
POPOR1detail2.Insert()
End If
End If
POPOR1detail1.Insert()
'_VerifyInventoryItem(segment, r.txt_Item_Description, aHeader, r)
Catch ex As Exception
Me._SysError("Exception in _CreatePO", True)
aHeader.txt_ActionRequired = "2ACCPAC"
End Try
End If
Next
POPOR1detail1Fields.FieldByName("PORLREV").PutWithoutVerification("-1") ' Line Number
POPOR1detail1.Read()
POPOR1detail4Fields.FieldByName("FUNCTION").PutWithoutVerification("8") ' Function