Skip to Content
0
Former Member
Nov 24, 2009 at 12:17 PM

Purchase Order

93 Views

Hi All,

How to add purchase order using code (not using object-id of PO form)

1.I want to create Purchase order dynamically.

I tried with following code

Dim RetVal As Long
        Dim ErrCode As Long
        Dim ErrMsg As String
        'Create the Documents object 
        Dim vPurchaseOrder As SAPbobsCOM.Documents
        vPurchaseOrder = objMain.objCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseOrders)
        'Set values to the fields 
        'vPurchaseOrder.Series = 0
        vPurchaseOrder.Series = 0
        vPurchaseOrder.CardCode = "BP234"
        vPurchaseOrder.HandWritten = SAPbobsCOM.BoYesNoEnum.tNO
        vPurchaseOrder.PaymentGroupCode = "-1"
        vPurchaseOrder.DocDate = DateTime.Today
        vPurchaseOrder.DocTotal = 264.6
        'Invoice Lines - Set values to the first line 
        vPurchaseOrder.Lines.ItemCode = "A00023"
        vPurchaseOrder.Lines.ItemDescription = "Banana"
        vPurchaseOrder.Lines.PriceAfterVAT = 2.36
        vPurchaseOrder.Lines.Quantity = 50
        vPurchaseOrder.Lines.Currency = "Eur"
        vPurchaseOrder.Lines.DiscountPercent = 10
        'Invoice Lines - Set values to the second line 
        vPurchaseOrder.Lines.Add()
        vPurchaseOrder.Lines.ItemCode = " A00033"
        vPurchaseOrder.Lines.ItemDescription = "Orange"
        vPurchaseOrder.Lines.PriceAfterVAT = 118
        vPurchaseOrder.Lines.Quantity = 1
        vPurchaseOrder.Lines.Currency = "Eur"
        vPurchaseOrder.Lines.DiscountPercent = 10
        vPurchaseOrder.Lines.Add()
        vPurchaseOrder.Lines.ItemCode = " A00034"
        vPurchaseOrder.Lines.ItemDescription = "mangoOrange"
        vPurchaseOrder.Lines.PriceAfterVAT = 118
        vPurchaseOrder.Lines.Quantity = 1
        vPurchaseOrder.Lines.Currency = "Eur"
        vPurchaseOrder.Lines.DiscountPercent = 10
 
 
        'Add the Invoice 
        RetVal = vPurchaseOrder.Add
        'Check the result 
        If RetVal  0 Then
            'objMain.objCompany.GetLastError(ErrCode, ErrMsg)
            MsgBox(ErrCode & " " & ErrMsg)
        End If

This code shows error

Datasource no data fond...!!!

Here directly im assigning values . How we can assign datssource to this code

by

Firos