📚 SAP Business One SDK Help

Create Order from a Draft Document
See Also

Description

This sample saves a draft document to xml and then creates a new order based on the xml.
Private Sub cmdDraftToOrder_Click()

    Dim pDraft As SAPbobsCOM.Documents
    Set pDraft = vCmp.GetBusinessObject(oDrafts)
    Dim pOrder As SAPbobsCOM.Documents
    vCmp.XmlExportType = xet_ExportImportMode
    vCmp.XMLAsString = False
    pDraft.GetByKey (3)
    pDraft.SaveXML ("c:\drafts.xml")

    'Here you should add a code that will change the Object's
    'value from 112 (Drafts) to 17 (Orders) and also you should
    'remove the DocObjectCode node from the xml. You can use any
    'xml parser.
    '
    'Create a new order
    Set pOrder = vCmp.GetBusinessObjectFromXML("c:\drafts.xml", 0)
    pOrder.Add

End Sub