SAP B1 How to create approved document from approved draft via SDK

536 views Asked by At

I've tried sample code like this;

SAPbobsCOM.Documents oDocDraft = SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts);<br>oDocDraft.GetByKey(docEntry);<br>oDocDraft.SaveDraftToDocument();

but this only creates regular document(doesn't have any information about approval status).

Also it does not generate process history on linked tables(ordr,owdd,wdd1) when the draft created via SDK

Is it possible to create approved document via SDK? If so I need an example about how to achieve that(c# code preferably). Any help would be much appreciated.

2

There are 2 answers

0
DEPARTED On BEST ANSWER

You should use SaveDraftToDocument method of Document interface. "Converts an approved draft document to a valid document." - this is from sdk documentation.

0
Praxiom On

when creating your new Document via the DI-API also set the Base Fields

 myNewDoc.Lines.BaseType = myDraftDoc.Lines.BaseType
 myNewDoc.Lines.BaseEntry = myDraftDoc.Lines.BaseEntry
 myNewDoc.Lines.BaseLine = myDraftDoc.Lines.BaseLine

this will ensure everything links up correctly.