on 2004 Nov 04 6:42 AM
Hi All, I have tried to import various business objects via XML without success. I have read all the related postings on this site and none seems to work for me. I am new to the SDK so the problem is most probably quite simple. My other big problem is that I'm also new to VB as Delphi doesn't always work with the SDK. My code is as follows in VB.Net 2002
Dim aSO As SAPbobsCOM.Documents
oCompany.XmlExportType = SAPbobsCOM.BoXmlExportTypes.xet_ValidNodesOnly
aSO = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders)
aSO.GetByKey("1")
aSO.SaveXML("c:\SO1.xml")
aSO = Nothing
aSO = oCompany.GetBusinessObjectFromXML("c:\SO1.xml", 0)
In the last line I get an error "An unhandled exception of type System.Runtime.InteropServices.COMException occurred. Additional Information: <ErrorList><Error>System Id = 9317472, Line Number = 1, Column Number = 108, Description = Unknown Element 'DocEntry'
<ErrorList><Error>System Id = 9319936, Line Number = 1, Column Number = 168, Description = Unknown Element 'CANCELED'...
The list goes on and on. Your advise is appreciated.
Thanks in advance,
Adele
I guess the problem is your XML-file. You cannot
import exactly the same as you export. There are unique keys.
With your code I got the same problem as you. Using
a small XML-importfile it works at my computer.
Try to make your own simple XML-order like this,
remeber to save as unicode and change <cardcode> and
<itemcode> to something that exists on your system:
<?xml version="1.0" encoding="UTF-16" ?>
<BOM>
<BO>
<AdmInfo>
<Object>17</Object>
</AdmInfo>
<ORDR>
<row>
<CardCode>K00001</CardCode>
<DocDueDate>20041128</DocDueDate>
</row>
</ORDR>
<RDR1>
<row>
<ItemCode>A00001</ItemCode>
<Quantity>15</Quantity>
</row>
</RDR1>
<OSRI />
<OIBT />
<RDR2 />
<RDR3 />
</BO>
</BOM>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try to use the option
diCompany.XmlExportType = SAPbobsCOM.BoXmlExportTypes.xet_ExportImportMode
It worked for me.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Adele,
I think your problem is that you have forgot to set the object. Your statement should look like:
set aSO = oCompany.GetBusinessObjectFromXML("c:\SO1.xml", 0)
best regards
Ole
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the reply. If I add the "set" at the beginning of the line it just disappears when I move my cursor to the next line. I have also tried this with some code I copied off this forum. The code is...
Private Function XMLRead(ByVal oCompany As SAPbobsCOM.Company, ByVal vOrder As SAPbobsCOM.Documents)
Dim ret As Long
Dim FileName As String
Dim Ecount As Long
Dim ii As Long
Dim i As Long
vOrder = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders)
FileName = "C:\SO1.xml"
Ecount = oCompany.GetXMLelementCount(FileName)
For ii = 0 To Ecount - 1
If oCompany.GetXMLobjectType(FileName, ii) = SAPbobsCOM.BoObjectTypes.oOrders Then
'Read the Business object data
<b>vOrder = oCompany.GetBusinessObjectFromXML(FileName, ii)</b>
Exit For
End If
Next ii
ret = vOrder.Add
End Function
I get the same error as shown in my first post. It gets the error on the line marked in bold.
Hi Adele,
This problem has happen to me once. I used to have a user field in the marketing documents header. The problem guide me to see that the column which was cousing the error was this user field. I only delete it from the marketing documents and it worked properly.
Looking to your message error, I could not tell you if it is the same error. Do you have any user defined fields on the marketing documents header?
Just try to open the xml, and go to the involved columns, and watch out for something strange.
Hope helps,
Ibai Peñ
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
105 | |
8 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.