Skip to Content
0
Former Member
Jul 25, 2006 at 08:23 PM

Help. Business Object abort error.

25 Views

Hi.

I'm doing a program (below) and i am using DI API.

I'm trying to entry a material in stock (goods receipt), but the program is aborting.

The message error is: un-time exception thrown : System.NullReferenceException - Object reference not set to an instance of an object.

I am using SBO 2004.2B and VB.NET (2003).

Sorry my english.

My best regards.

Marcelo Valforte Castelucci

marcelo@agl.com.br

Option Strict Off

Option Explicit On

Imports VB = Microsoft.VisualBasic

Module modpsiglasbop

Public strMensagem As String

Dim vCmp As SAPbobsCOM.Company

Dim vDocEntrada As SAPbobsCOM.Documents

Dim lRetVal As Integer

Dim lRetCode As Object

Dim lErrCode As Integer

Dim sErrMsg As String

Public Sub Main()

EntradaEstoque()

End Sub

Public Sub EntradaEstoque()

MsgBox("Conectando no SAP Business One")

vCmp = New SAPbobsCOM.Company

vCmp.Server = "MARCELOMARCELO" 'Name of the DB Server

vCmp.CompanyDB = "SBOdemo_Brazil" 'Enter the name of your company

vCmp.UserName = "manager" 'Enter the B1 user name

vCmp.Password = "manager" 'Enter the B1 password

vCmp.language = SAPbobsCOM.BoSuppLangs.ln_Portuguese_Br 'Enter the logon language

vCmp.UseTrusted = True

lRetCode = vCmp.Connect

If lRetCode <> 0 Then

vCmp.GetLastError(lErrCode, sErrMsg)

End If

MsgBox("Conectado no SAP Business One")

'conecta_db_sbo()

vDocEntrada = vCmp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryGenEntry)

'header

vDocEntrada.HandWritten = SAPbobsCOM.BoYesNoEnum.tNO

vDocEntrada.PaymentGroupCode = -1

'vDocEntrada.DocNum = 5

vDocEntrada.Series = 20

vDocEntrada.Comments = "Documento originado por integração de sistemas"

vDocEntrada.CardCode = ""

vDocEntrada.DocDate = Now

vDocEntrada.TaxDate = Now

vDocEntrada.Reference2 = ""

vDocEntrada.JournalMemo = "Entrada de produção"

'item 1

vDocEntrada.Lines.ItemCode = "Bola"

vDocEntrada.Lines.Quantity = 10

vDocEntrada.Lines.AccountCode = "3.2.3.4.18 "

vDocEntrada.Lines.Price = 10

vDocEntrada.Lines.Add()

'Check the result

If vDocEntrada.Add <> 0 Then '----

-


abort here, method vDocEntrada.Add

vCmp.GetLastError(lErrCode, sErrMsg)

MsgBox(lErrCode & " " & sErrMsg)

Else

MsgBox("INCLUIDO")

End If

End Sub

End Module