Showing posts with label Visual Basic. Show all posts
Showing posts with label Visual Basic. Show all posts

Tuesday, January 12, 2010

How to Create A/P Invoice SAP B1 using SDK

What is an A/P Invoice?
A/P Invoice is abbreviations from Account Payable Invoice. Its account or the bill must be paid to vendor based on the goods we buy. Many vendor allowing to pay after product or service already been received.
To generate document A/P Invoice in SAP B1 is using oPurchaseInvoice object.
Here is the code:
Dim oAPInvoice As sapbobscom.Documents
Set oAPInvoice = oCompany.GetBusinessObject(sapbobscom.BoObjectTypes.oPurchaseInvoices)
With oAPInvoice
‘Header area
.CardCode = your vendor code
.NumAtCard = your reference no
.DocDate = your posting date
.TaxDate = your document date
.DocType = sapbobscom.BoDocumentTypes.dDocument_Items
.Comments = your remarks
‘Detail area
.Lines.SetCurrentLine (detail rows)
.Lines.itemCode = your item code
.Lines.WarehouseCode = your warehouse code
.Lines.Quantity = your qty
.Lines.VatGroup = "ZI"
.Lines.UnitPrice = F_Price
.Lines.LineTotal = F_Amount
LngErr = .Add()
If LngErr <> 0 Then
oCompany.GetLastError(LngErr, sErrMsg)
Msgbox SErrMsg
Else
MsgBox “Create A/P Invoice Data Success”
End with
Note: If your vendor use Tax amount, you can setup first on Business partner master - allowed tax

Friday, January 8, 2010

How to Connect SAP with Visual Basic

SAP Business One able integrates with another software development such as Visual Basic 6 and .Net.
Now, I will share to you how to connect SAP B1 using visual basic.
First you must be installing SDK SAP B1, after that you must add SAP business one DI API version on Visual basic Reference.
Below is the source code.

Public oCompany as SAPbobsCOM.Company
Public lerr As Long, sErr As String
    Set oCompany = New SAPbobsCOM.Company
    With oCompany
        .Server = your SAP Server name
        .CompanyDB = your SAP Database name
        .UserName = your SAP user
        .Password = your SAP password
        .DbServerType = dst_MSSQL2005
        .language = ln_English
        .UseTrusted = False
        .DbUserName = your SQL database user name
        .DbPassword = your SQL database password name
   
    lerr = oCompany.Connect()
        If lerr <> 0 Then
            Call oCompany.GetLastError(lerr, sErr)
            MsgBox sErr           
        Else
            Msgbox “Connected to SAP B1”
        End If
       
    End With
Note: Make sure your user id and password set correctly. System will lock your user id if you input invalid login until 3 times