on 2014 May 15 4:12 AM
Hi All,
When I update the existing good receipt PO because the project field is changed, the project field in JE lines of the good receipt PO do not change.
The error message appear as follows:
"Conversion from type 'IJournalEntries' to type 'String' is not valid."
I use SDK addon to update it. Here is the code as follows:
Module JEProjectUpdate
Public Sub UpdateJournalEntry(ByRef BusinessObjectInfo As SAPbouiCOM.BusinessObjectInfo, ByRef BubbleEvent As Boolean)
If BusinessObjectInfo.FormTypeEx = "143" OrElse _
BusinessObjectInfo.FormTypeEx = "182" OrElse _
BusinessObjectInfo.FormTypeEx = "180" OrElse _
BusinessObjectInfo.FormTypeEx = "140" OrElse _
BusinessObjectInfo.FormTypeEx = "170" Then
End If
If BusinessObjectInfo.EventType = SAPbouiCOM.BoEventTypes.et_FORM_DATA_UPDATE Or _
BusinessObjectInfo.EventType = SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD Then
Dim oForm As SAPbouiCOM.Form
oForm = CType(M_SBOApplication.Forms.Item(BusinessObjectInfo.FormUID), SAPbouiCOM.Form)
Dim oCBO As SAPbouiCOM.EditText
If BusinessObjectInfo.FormTypeEx = "170" Or BusinessObjectInfo.FormTypeEx = "426" Then
oCBO = CType(oForm.Items.Item("95").Specific, SAPbouiCOM.EditText)
Else
oCBO =
CType(oForm.Items.Item("157").Specific, SAPbouiCOM.EditText)
End If
Dim sJEBaseDocNum As String = ""
If BusinessObjectInfo.ActionSuccess = True Then
Dim oDoc As SAPbobsCOM.Documents = Nothing
Dim oPay As SAPbobsCOM.Payments = Nothing
Dim oJE As SAPbobsCOM.JournalEntries
If BusinessObjectInfo.FormTypeEx = "143" Then 'Good Receipt PO
oDoc = CType(M_SBOCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseDeliveryNotes), SAPbobsCOM.Documents)
sJEBaseDocNum = "Good Receipt PO"
ElseIf BusinessObjectInfo.FormTypeEx = "182" Then 'Good returns
oDoc = CType(M_SBOCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseReturns), SAPbobsCOM.Documents)
sJEBaseDocNum = "Good Returns"
ElseIf BusinessObjectInfo.FormTypeEx = "180" Then 'AR Returns
oDoc = CType(M_SBOCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oReturns), SAPbobsCOM.Documents)
sJEBaseDocNum = "AR Returns"
ElseIf BusinessObjectInfo.FormTypeEx = "140" Then 'Delivery
oDoc = CType(M_SBOCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDeliveryNotes), SAPbobsCOM.Documents)
sJEBaseDocNum = "Delivery Notes"
End If
If BusinessObjectInfo.FormTypeEx = "170" Then 'incoming payment
oPay.Browser.GetByKeys(BusinessObjectInfo.ObjectKey)
sJEBaseDocNum = "Incoming payment # " + CStr(oPay.DocNum)
oJE = CType(M_SBOCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oJournalEntries), SAPbobsCOM.JournalEntries)
Dim oRec As SAPbobsCOM.Recordset
oRec = CType(M_SBOCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset), SAPbobsCOM.Recordset)
oRec.DoQuery("SELECT TransId FROM ORCT WHERE DocEntry = " + oPay.DocEntry.ToString)
If oRec.RecordCount > 0 Then
oJE.GetByKey(CInt(oRec.Fields.Item("TransId").Value))
End If
ElseIf BusinessObjectInfo.FormTypeEx = "426" Then 'outgoing payment
oPay.Browser.GetByKeys(BusinessObjectInfo.ObjectKey)
sJEBaseDocNum = "Outgoing payment # " + CStr(oPay.DocNum)
oJE = CType(M_SBOCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oJournalEntries), SAPbobsCOM.JournalEntries)
Dim oRec As SAPbobsCOM.Recordset
oRec = CType(M_SBOCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset), SAPbobsCOM.Recordset)
oRec.DoQuery("SELECT TransId FROM OVPM WHERE DocEntry = " + oPay.DocEntry.ToString)
If oRec.RecordCount > 0 Then
oJE.GetByKey(CInt(oRec.Fields.Item("TransId").Value))
End If
Else
oDoc.Browser.GetByKeys(BusinessObjectInfo.ObjectKey)
sJEBaseDocNum = sJEBaseDocNum + " no " + CStr(oDoc.DocNum)
oJE = CType(M_SBOCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oJournalEntries), SAPbobsCOM.JournalEntries)
oJE.GetByKey(oDoc.TransNum)
End If
oJE.ProjectCode = oCBO.Value()
oJE.Lines.ProjectCode = oCBO.Value()
Dim i As Integer
Dim JrnNumber As Integer = 0
If oJE.GetByKey(JrnNumber) Then
For i As Integer = 0 To oJE.Lines.Count - 1
oJE.Lines.SetCurrentLine(i)
oJE.Lines.ProjectCode = CStr(oCBO.Equals(i))
Next
Next
M_SBOCompany.StartTransaction()
Dim updateStatus As Integer
Dim sErrMsg As String = ""
updateStatus = oJE.Update()
If updateStatus <> 0 Then
M_SBOCompany.GetLastError(updateStatus, sErrMsg)
LogToSBODB(M_SBOCompany, "Failed updating Project field of JE by " + sJEBaseDocNum, CStr(updateStatus) + ":" + sErrMsg, EnumMEBAddonLogType.ErroType.ToString, CStr(EnumMEBAddonLogCategory.JEProjectUpdate), "", M_SBOCompany.UserName)
M_SBOApplication.StatusBar.SetText("failed updating Project field of JE by " + sJEBaseDocNum, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error)
M_SBOCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)
Else
If M_SBOCompany.InTransaction Then
M_SBOCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit)
End If
End If
End If
End If
End If
End Sub
End Module
The error messages in the debug or vb.net of visual studio are
1. Variable 'i' hides a variable in an enclosing block
2. 'Next' must be preceded by a matching 'For'.
Please provide a solution for this issue.
Thank you
Rgds,
Steve
hi.
u said..
"Conversion from type 'IJournalEntries' to type 'String' is not valid."
ok
in this line
oJE.Lines.ProjectCode = CStr(oCBO.Equals(i))
here
CStr(oCBO.Equals(i)) this string is having which value..
put break point here and check it...
which value it is storing...ok
after that
open b1 and try to post new je through the manually with CStr(oCBO.Equals(i)) this value
suppose CStr(oCBO.Equals(i)) is having 'Project1'
try to post the je with project1 then check it whether u are getting the error or not...
And At what line u r getting error have u checked it...
put break point and check it..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
98 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.