cancel
Showing results for 
Search instead for 
Did you mean: 

DI: Importing an order from a XML-document

Former Member
0 Kudos

Hi,

I've got a problem with importing an order from a xml document. The document was exported by the savexml method and now I want to reimport it. But I only can get the first line of the order whether there two more lines in it. When I am running my program, it enters the first line and than it stops with the following error:

<b><i>An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in XML enter.exe

Additional information: Exception from HRESULT: 0xFFFFFC16.</i></b>

The source code is the following:

Dim vCmp As SAPbobsCOM.Company

Dim nResult As Long, i As Long, ii As Long

Dim strErrString As String

vCmp = New SAPbobsCOM.Company

'Initialize the Company Object for the Connect hod

vCmp.Server = "(local)"

vCmp.CompanyDB = "test"

vCmp.UserName = "manager"

vCmp.Password = "manager"

vCmp.language = PbobsCOM.BoSuppLangs.ln_English_Gb

vCmp.UseTrusted = True

'Connect to the database

nResult = vCmp.Connect

If nResult <> 0 Then

vCmp.GetLastError(nResult, strErrString)

MsgBox(strErrString)

Else

vCmp.XmlExportType = .BoXmlExportTypes.xet_ValidNodesOnly

Dim vBP As SAPbobsCOM.Documents

Dim vBPXML As SAPbobsCOM.Documents

vBPXML = vCmp.GetBusinessObjectFromXML("D:\XMLDocs\mod2.XML", 0)

vBP = vCmp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders)

vBP.DocNum = vBPXML.DocNum

vBP.DocType = vBPXML.DocType

vBP.HandWritten = vBPXML.HandWritten

vBP.DocDate = vBPXML.DocDate

vBP.DocDueDate = vBPXML.DocDueDate

vBP.CardCode = vBPXML.CardCode

vBP.CardName = vBPXML.CardName

vBP.Address = vBPXML.Address

vBP.DiscountPercent = vBPXML.DiscountPercent

vBP.DocCurrency = vBPXML.DocCurrency

vBP.DocRate = vBPXML.DocRate

vBP.DocTotal = vBPXML.DocTotal

vBP.Reference1 = vBPXML.Reference1

vBP.Reference2 = vBPXML.Reference2

vBP.Comments = vBPXML.Comments

vBP.JournalMemo = vBPXML.JournalMemo

vBP.PaymentGroupCode = vBPXML.PaymentGroupCode

vBP.DocTime = vBPXML.DocTime

vBP.SalesPersonCode = vBPXML.SalesPersonCode

vBP.TransportationCode = vBPXML.TransportationCode

vBP.PartialSupply = vBPXML.PartialSupply

vBP.Confirmed = vBPXML.Confirmed

vBP.SummeryType = vBPXML.SummeryType

vBP.WareHouseUpdateType = vBPXML.WareHouseUpdateType

vBP.ContactPersonCode = vBPXML.ContactPersonCode

vBP.ShowSCN = vBPXML.ShowSCN

vBP.Series = vBPXML.Series

vBP.TaxDate = vBPXML.TaxDate

vBP.Indicator = vBPXML.Indicator

vBP.ShipToCode = vBPXML.ShipToCode

vBP.FederalTaxID = vBPXML.FederalTaxID

vBP.Form1099 = vBPXML.Form1099

vBP.Box1099 = vBPXML.Box1099

vBP.Rounding = vBPXML.Rounding

vBP.RevisionPo = vBPXML.RevisionPo

vBP.RequriedDate = vBPXML.RequriedDate

vBP.CancelDate = vBPXML.CancelDate

vBP.BlockDunning = vBPXML.BlockDunning

vBP.MaximumCashDiscount = vBPXML.MaximumCashDiscount

vBP.CentralBankIndicator = vBPXML.CentralBankIndicator

vBP.Project = vBPXML.Project

vBP.DeferredTax = vBPXML.DeferredTax

vBP.TaxExemptionLetterNum = vBPXML.TaxExemptionLetterNum

vBP.ExemptionValidityDateFrom = vBPXML.ExemptionValidityDateFrom

vBP.ExemptionValidityDateTo = vBPXML.ExemptionValidityDateTo

vBP.AgentCode = vBPXML.AgentCode

vBP.NumberOfInstallments = vBPXML.NumberOfInstallments

vBP.VatDate = vBPXML.VatDate

vBP.ExternalCorrectedDocNum = vBPXML.ExternalCorrectedDocNum

vBP.InternalCorrectedDocNum = vBPXML.InternalCorrectedDocNum

ii = vBPXML.Lines.Count - 1

For i = 0 To ii

vBP.Lines.SetCurrentLine(i)

vBPXML.Lines.SetCurrentLine(i)

vBP.Lines.BaseType = vBPXML.Lines.BaseType

vBP.Lines.BaseEntry = vBPXML.Lines.BaseEntry

vBP.Lines.BaseLine = vBPXML.Lines.BaseLine

vBP.Lines.ItemCode = vBPXML.Lines.ItemCode

vBP.Lines.ItemDescription = vBPXML.Lines.ItemDescription

vBP.Lines.Quantity = vBPXML.Lines.Quantity

vBP.Lines.ShipDate = vBPXML.Lines.ShipDate

vBP.Lines.Price = vBPXML.Lines.Price

vBP.Lines.Currency = vBPXML.Lines.Currency

vBP.Lines.Rate = vBPXML.Lines.Rate

vBP.Lines.DiscountPercent = vBPXML.Lines.DiscountPercent

vBP.Lines.LineTotal = vBPXML.Lines.LineTotal

vBP.Lines.VendorNum = vBPXML.Lines.VendorNum

vBP.Lines.SerialNum = vBPXML.Lines.SerialNum

vBP.Lines.WarehouseCode = vBPXML.Lines.WarehouseCode

vBP.Lines.SalesPersonCode = vBPXML.Lines.SalesPersonCode

vBP.Lines.CommisionPercent = vBPXML.Lines.CommisionPercent

vBP.Lines.AccountCode = vBPXML.Lines.AccountCode

vBP.Lines.TaxLiable = vBPXML.Lines.TaxLiable

vBP.Lines.UseBaseUnits = vBPXML.Lines.UseBaseUnits

vBP.Lines.SupplierCatNum = vBPXML.Lines.SupplierCatNum

vBP.Lines.CostingCode = vBPXML.Lines.CostingCode

vBP.Lines.ProjectCode = vBPXML.Lines.ProjectCode

vBP.Lines.BarCode = vBPXML.Lines.BarCode

vBP.Lines.TaxPercentagePerRow = vBPXML.Lines.TaxPercentagePerRow

vBP.Lines.VatGroup = vBPXML.Lines.VatGroup

vBP.Lines.PriceAfterVAT = vBPXML.Lines.PriceAfterVAT

vBP.Lines.Height1 = vBPXML.Lines.Height1

vBP.Lines.Hight1Unit = vBPXML.Lines.Hight1Unit

vBP.Lines.Height2 = vBPXML.Lines.Height2

vBP.Lines.Height2Unit = vBPXML.Lines.Height2Unit

vBP.Lines.Width1 = vBPXML.Lines.Width1

vBP.Lines.Width1Unit = vBPXML.Lines.Width1Unit

vBP.Lines.Width2 = vBPXML.Lines.Width2

vBP.Lines.Width2Unit = vBPXML.Lines.Width2Unit

vBP.Lines.Lengh1 = vBPXML.Lines.Lengh1

vBP.Lines.Lengh1Unit = vBPXML.Lines.Lengh1Unit

vBP.Lines.Lengh2 = vBPXML.Lines.Lengh2

vBP.Lines.Lengh2Unit = vBPXML.Lines.Lengh2Unit

vBP.Lines.Volume = vBPXML.Lines.Volume

vBP.Lines.VolumeUnit = vBPXML.Lines.VolumeUnit

vBP.Lines.Weight1 = vBPXML.Lines.Weight1

vBP.Lines.Weight1Unit = vBPXML.Lines.Weight1Unit

vBP.Lines.Weight2 = vBPXML.Lines.Weight2

vBP.Lines.Weight2Unit = vBPXML.Lines.Weight2Unit

vBP.Lines.Factor1 = vBPXML.Lines.Factor1

vBP.Lines.Factor2 = vBPXML.Lines.Factor2

vBP.Lines.Factor3 = vBPXML.Lines.Factor3

vBP.Lines.Factor4 = vBPXML.Lines.Factor4

vBP.Lines.Address = vBP.Lines.Address

vBP.Lines.TaxCode = vBPXML.Lines.TaxCode

'vBP.Lines.TaxType = vBPXML.Lines.TaxType

vBP.Lines.BackOrder = vBPXML.Lines.BackOrder

vBP.Lines.FreeText = vBPXML.Lines.FreeText

vBP.Lines.ShippingMethod = vBPXML.Lines.ShippingMethod

vBP.Lines.DeferredTax = vBPXML.Lines.DeferredTax

vBP.Lines.CorrectionInvoiceItem = vBPXML.Lines.CorrectionInvoiceItem

vBP.Lines.CorrInvAmountToDiffAcct = vBPXML.Lines.CorrInvAmountToDiffAcct

vBP.Lines.CorrInvAmountToStock = vBPXML.Lines.CorrInvAmountToStock

MsgBox(i)

Next i

vBP.Add()

Call vCmp.GetLastError(nResult, strErrString)

If nResult <> 0 Then

MsgBox(strErrString)

Else

MsgBox("OK - Done!")

End If

End If

vCmp.Disconnect()

vCmp = Nothing

I hope someone can help me with my problem.

Regards,

Dennis

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Thank's for your help. Now it works almost perfect.

There are only two fields in the order table after entering an order from xml which I can't understand.

These fields are DiscSumSy and RoundDifSy. In the data record I entered with the SAP BO client they have got no value. If I enter the same order from a xml document, these fields receive values I can't explain. Do you know what these two fields are for and why there is a value whether I didn't enter one??

Perhaps you can help me with this problem too.

Regards,

Dennis

former_member185703
Active Contributor
0 Kudos

Hi Dennis,

ASFAIK those fields are for (SC = system currency)

DiscSumSy "Total Discount (SC)"

RoundDifSy "Rounding Diff. Amount (SC)"

I think the values are calculated automatically when you add an order.

And hopefully they are recalculated even in your case when you create the order from a XML-document...

Could this be the answer to your question?

Regards,

Frank

former_member185703
Active Contributor
0 Kudos

Hi Dennis,

please note that your new object comes up with one empty line (as any new object that has got "lines" in SBO).

That's why your approach works for line no. 0.

If you want to have a second line you must "Add" it before filling it!

best regards,

Frank