cancel
Showing results for 
Search instead for 
Did you mean: 

Web Service SAP BO

bfierro
Active Participant
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

former_member185682
Active Contributor
0 Kudos

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

bfierro
Active Participant
0 Kudos

Thanks for the reply.

They recommend me to use for creating Web service ?.

You have the piece of code where the object and the connection to the database is assigned SAP BO.

Thank you.

former_member185682
Active Contributor
0 Kudos

It works, but is very slowly and sometimes make a crash em iis service.

I don't have any other suggestions now .

About the sample code, the begin and the end is equal your propose.

Regards,

Diego

bfierro
Active Participant
0 Kudos

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

former_member185682
Active Contributor
0 Kudos

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

Answers (0)