on 12-29-2015 12:25 PM
HI
I am creating a web service from asp.net, very simple, to create a seat ("Memo") using the Di API. But when testing sends me error "entry code ReferenceException not control Null".
The code is as follows:
<WebMethod()> _
Public Function prueba(ByVal msje As String) As String
Dim lRetCode As Long
Dim vDoc As SAPbobsCOM.JournalEntries
vDoc = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oJournalEntries)
' vDoc = oCompany.GetBusinessObject(oJournalEntries)
oCompany = New SAPbobsCOM.Company
oCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2008
oCompany.DbUserName = "XXXX"
oCompany.DbPassword = "XXXX"
oCompany.Server = "192.168.0.XX"
oCompany.CompanyDB = "SBO_INFORMATICA"
oCompany.UserName = "XXX"
oCompany.Password = "XXX"
oCompany.UseTrusted = False
'oCompany.language = "ln_Spanish_La"
lRetCode = oCompany.Connect()
vDoc.Memo = msje
vDoc.Lines.Debit = 2000
vDoc.Lines.Credit = 2000
lRetCode = vDoc.Add()
If lRetCode <> 0 Then
oCompany.GetLastError(lErrCode, sErrMsg)
MsgBox(lErrCode & " " & sErrMsg) ' Display error message
Else
MsgBox("Asiento Creado", MsgBoxStyle.Information)
End If
oCompany.Disconnect()
End Function
The idea is then to consume this web service from a web application. (ASP.NET)
thanks.
Hi Boris,
About your scenario, I believe that will you find some problems in future because DI API is very slow.
About your error, for to create a memo(JournalEntries), some fields are necessary:
Try this sample available in help of sdk:
vJE.TaxDate = Now;
vJE.Lines.AccountCode = "110000";
vJE.Lines.ContraAccount = "10110";
vJE.Lines.Credit = 0;
vJE.Lines.Debit = 150;
vJE.Lines.DueDate = Convert.ToDateTime("11/13/ 2002");
vJE.Lines.ReferenceDate1 = Now;
vJE.Lines.ShortName = "110000";
vJE.Lines.TaxDate = Now;
vJE.Lines.Add;
vJE.Lines.SetCurrentLine(1);
vJE.Lines.AccountCode = "10110";
vJE.Lines.ContraAccount = "110000";
vJE.Lines.Credit = 150;
vJE.Lines.Debit = 0;
vJE.Lines.DueDate = Convert.ToDateTime("11/13/ 2002");
vJE.Lines.Line_ID = 1;
vJE.Lines.ReferenceDate1 = Now;
vJE.Lines.ShortName = "10110";
vJE.Lines.TaxDate = Now;
if ((0 != vJE.Add())) {
Interaction.MsgBox("failed to add a journal entry");
} else {
Interaction.MsgBox("Succeeded in adding a journal entry");
vJE.SaveXml("c:\\temp\\JournalEntries" + Conversion.Str(vJE.JdtNum) + ".xml");
}
Hope it helps,
Regards,
Diego
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Diego.
He sends error in the part of the connection, re order code follows.
The strange thing is that sends error connecting to the SBO-COMMONS
<WebMethod()> _
Public Function prueba(ByVal msje As String) As String
Dim lRetCode As Long
oCompany = New SAPbobsCOM.Company
oCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2008
oCompany.DbUserName = "[XX]"
oCompany.DbPassword = "[XX]"
oCompany.Server = "[XXXXXX]"
oCompany.CompanyDB = "[XXXXXX]"
oCompany.UserName = "[XXXX]"
oCompany.Password = "[XXXXX]"
oCompany.UseTrusted = False
oCompany.language = SAPbobsCOM.BoSuppLangs.ln_Spanish_La
lRetCode = oCompany.Connect()
If lRetCode <> 0 Then
MsgBox(oCompany.GetLastErrorDescription())
Else
Dim vDoc As SAPbobsCOM.JournalEntries
vDoc = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oJournalEntries)
vDoc.Memo = "Prueba"
vDoc.Lines.AccountCode = "_SYS00000000117"
vDoc.Lines.ContraAccount = "_SYS00000000117"
vDoc.Lines.ShortName = "_SYS00000000117"
vDoc.Lines.CostingCode = 301
vDoc.Lines.Debit = 2000
vDoc.Lines.Credit = 2000
lRetCode = vDoc.Add()
If lRetCode <> 0 Then
oCompany.GetLastError(lErrCode, sErrMsg)
MsgBox(lErrCode & " " & sErrMsg) ' Display error message
Else
MsgBox("Asiento Creado", MsgBoxStyle.Information)
End If
Return "Create"
oCompany.Disconnect()
End If
End Function
Thanks
Hi Boris,
Some situations can cause this issue, some suggestions:
1 - Your server that you provide in oCompany.Server, should be equals server information in your service manager, if you use ip in your service manager, you need use ip in your property. If you use hostname in your service manager, you need use hostname in your property.
2 - Try provide oCompany.LicenseServer in your code, before you call connect method.
Hope it helps,
Regards,
Diego
User | Count |
---|---|
91 | |
7 | |
7 | |
4 | |
3 | |
3 | |
3 | |
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.