Skip to Content
0
Former Member
Dec 01, 2006 at 12:11 AM

having issues with Creating a budget using DI

86 Views

Version is 2005A SP00 to SP01

I need to create a brand new Budet using the DI.

I have some code that I fiddled with but does not work. I am not sure why. Appreciate if anyone points out any silly mistakes I am doing.

In my example below, I gave 2 company objects. One connecting to teh source SAP company and teh other to teh destination SAP company. I retrieve an existing budget from teh source company and try to create a new Budget in the destination with the source budget information except for the Budget scenario number. all other budget settings etc are the same in both companies.

Private Function CreateBudget()
    Dim oMyBudgetLines As SAPbobsCOM.Budget_Lines
    Dim oSourceBudget As SAPbobsCOM.Budget
   
    'destiation objects
    Dim oDestBudget As SAPbobsCOM.Budget
    Dim oDestBudgetLines As SAPbobsCOM.Budget_Lines
    Set oDestBudget = gObjDestinationCompany.GetBusinessObject(oBudget)
    gObjDestinationCompany.XmlExportType = xet_ExportImportMode
        
    Set oSourceBudget = gObjCompany.GetBusinessObject(oBudget)
    gObjCompany.XmlExportType = xet_ExportImportMode
    
    oSourceBudget.GetByKey (15)
    Set oDestBudget = oSourceBudget
    
    '---I have created a Budget Scenario with the number 4 in the
    'destination company
    oDestBudget.BudgetScenario = 4
    
    oDestBudget.Add
    
    'the folling line if I tried will hang foever
    'oDestBudget.Update

End Function