Skip to Content
author's profile photo Former Member
Former Member

Best way to update sales orders using xml

Hi Guys,

We are building some functionality to import sales orders and deleveries from an other company to a new database.

Now the creating of the sales orders works fine, by using the code below.

Now i'm looking for example code to update the orders the same way.

I found some different ways to do this.

Can anyone tell me what the best option will be to update sales order.

Please provide some example code.

I would also like to know which version of sbo xml syntax to use.

For example

<AdmInfo>
   <Object>17</Object>
   <Version>2</Version>
  </AdmInfo>
  <Documents>
   <row>

or

<AdmInfo>
   <Object>17</Object>
  </AdmInfo>
  <ORDR>
   <row>

Thanks in advance

public static void CreateSalesOrderFromXML(String xmlString, SAPbobsCOM.Company company)
{
company.XMLAsString = true;
company.XmlExportType = SAPbobsCOM.BoXmlExportTypes.xet_ExportImportMode; int elements = company.GetXMLelementCount(xmlString); for (int i = 0; i < elements; i++)
{
if (company.GetXMLobjectType(xmlString, i) == BoObjectTypes.oOrders)
{
IDocuments salesOrder = (IDocuments)company.GetBusinessObjectFromXML(xmlString, i); try
{
Int32 result = 0; if (!SalesOrderExistsByDocNum(company, salesOrder.DocNum))
result = salesOrder.Add(); if (result != 0)
throw new Exception(company.GetLastErrorDescription());
}
finally
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(salesOrder);
salesOrder = null;
}
}
}
}
Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2014 at 12:36 AM

    Hi william,

    Regarding the syntax, the easiest is to start by exporting an existing object then to duplicate its header.

    A sales order is first a document and the version tag is mandatory. So version 1?

    Regards,

    Eric

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 09, 2014 at 09:17 PM

    Hi William,

    The xml schema relates to the Company.XmlExportType property in the DI API. You can use either format you've listed but you need to set the XmlExportType property accordingly (if the format you choose is not the default). More details on the formats can be found in the SDK documentation (look for the BoXmlExportTypes enumeration).

    I believe the first syntax is the preferred one for import and export of data (and it's the one used by B1if).

    Kind Regards,

    Owen

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.