Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

not connected to the company


Sorry but my english.

I'm trying my first code in Visual Basic using the SAP B1 SDK.

I'm using examples from the SDK Help to create a new item, but don't working...

This is my code

Module Module1

    Sub Main()
        'Definir variables
        Dim vCmp As SAPbobsCOM.Company
        Dim lRetCode, lErrCode As Long
        Dim sErrMsg As String

        'Iniciar objeto de la compaƱia
        vCmp = New SAPbobsCOM.Company

        'Definir datos de la coneccion
        vCmp.Server = "SERVER"      'Nombre del servidor
        vCmp.CompanyDB = "Data Base"              'Nombre de la compaƱia
        vCmp.UserName = "manager"                 'Usuario de SAP B1
        vCmp.Password = "1106"                    'Password usuario
        vCmp.language = "25"                      'Lenguaje de la coneccion

        'Definir coneccion al servidor
        '''''True = Authentication SQL Server
        vCmp.UseTrusted = True

        'Conectar a la base de SAP B1
        lRetCode = vCmp.Connect

        Dim RetVal As Long
        Dim ErrCode As Long
        Dim ErrMsg As String
        Dim vItem As SAPbobsCOM.Items

        'Definir objeto
        vItem = vCmp.GetBusinessObject(oItems)

        'Definir ItemCode
        vItem.ItemCode = "AAAAA"

        'Definir otros campos
        vItem.ItemName = "MyNewItemName"
        vItem.WhsInfo.WarehouseCode = "01"

	'Crear Item
        RetVal = vItem.Add()

        'Verificar el resultado
        '''''Para continuar el resultado debe ser 0
        '''''Si el resultado no es 0, verifica el error y el mensaje de error
        If lRetCode <> 0 Then
            vCmp.GetLastError(lErrCode, sErrMsg)
        End If

    End Sub

End Module

somebody can help me?



Former Member
Not what you were looking for? View more on this topic or Ask a question