Skip to Content
0

Closing a delivery note Draft with SDK

Feb 17, 2017 at 07:30 AM

155

avatar image
Former Member
Hello, I have created a Delivery document from a Delivery Draft, the problem is that the Draft remains open. so I need to close the Draft (with SDK)

in other words the Table ODRF have field DocStatus="O" and I need to set it to "C"

Doc_2 = oCompanyCOF.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts)

...

If oDoc_2.GetByKey(DocEntry_Draft) Then

oDoc_2.DocumentStatus = SAPbobsCOM.BoStatus.bost_Close (THIS IS READ ONLY)

end if

from SAP if I right click on the open draft I can very easily set it to CLOSE.. but how with SDK ?

Thank you

10 |10000 characters needed characters left characters exceeded

Hi Marco,

As far as I have been able to check it, there seems to be no possibility to do this straight away.

Close() method is not supported for Delivery Object.

If you need to Cancel an existing Delivery Document, you use CreateCancellationDocument() method but that seems not be there for Draft Delivery Document.

Why don't you try to Cancel it and later from the Draft Document report, select only 'Open Only' document?

Kind regards,

ANKIT CHAUHAN

SAP SME Support

0
* Please Login or Register to Answer, Follow or Comment.

5 Answers

DIEGO LOTHER Feb 17, 2017 at 02:51 PM
0

Hi Marco,

Another approach if the ANKIT solution does not fit your purpose, is to remove your draft.

                oDoc = oCompany.GetBusinessObject(BoObjectTypes.oDrafts);
                if(oDoc.GetByKey(key))
                {
                    if(oDoc.Remove() != 0)
                        MessageBox.Show(oCompany.GetLastErrorDescription());
                }

Hope it helps.

Kind Regards,

Diego Lother

Share
10 |10000 characters needed characters left characters exceeded
Edy Simon Feb 20, 2017 at 01:59 AM
0

Hi Marco,

How did you add the delivery from the draft in SDK ?
Are you using the oDraft.SaveDraftToDocument();

Regards

Edy

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Feb 20, 2017 at 08:51 AM
0

Hi thank you for your help,

To create the Delivery from the Draft:

oDoc = oCompanyCOF.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDeliveryNotes) 'DELIVERY
oDoc_2 = oCompanyCOF.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts) 'DRAFT

oDoc.CardCode = oDoc_2.CardCode
........
Dim NumRigeDraft As Integer = oDoc_2.Lines.Count
For CurrentLine As Integer = 0 To NumRigeDraft - 1
       ......
       oDoc.Lines.BaseEntry = oDoc_2.Lines.BaseEntry 
       oDoc.Lines.BaseType =  oDoc_2.Lines.BaseType 
       oDoc.Lines.BaseLine = oDoc_2.Lines.BaseLine


next


Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Feb 20, 2017 at 08:51 AM
0

Hi thank you for your help, (I will probably have to delete the draft)

To create the Delivery from the Draft this is my code:
oDoc = oCompanyCOF.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDeliveryNotes) 'DELIVERY
oDoc_2 = oCompanyCOF.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts) 'DRAFT

oDoc.CardCode = oDoc_2.CardCode
........
Dim NumRigeDraft As Integer = oDoc_2.Lines.Count
For CurrentLine As Integer = 0 To NumRigeDraft - 1
       ......
       oDoc.Lines.BaseEntry = oDoc_2.Lines.BaseEntry 
       oDoc.Lines.BaseType =  oDoc_2.Lines.BaseType 
       oDoc.Lines.BaseLine = oDoc_2.Lines.BaseLine
       .....
       oDoc.Lines.Add()
next

....

 Dim errCode As Integer = oDoc.Add()
Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Feb 20, 2017 at 09:08 AM
0

I did not used : SaveDraftToDocument

probably this is the reason why it didn't close !

I have to Update the Draft and than SaveDraftToDocument Right ? !

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Marco,

The correct way to convert your draft in a valid document is using the SaveDraftToDocument method() as mentioned by Edy.

The draft that stayed opened, you can cancel or remove it. But remember if you use the SaveDraftToDocument this situation will not occur.

Sample saveDraftToDocument:

                oDoc = oCompany.GetBusinessObject(BoObjectTypes.oDrafts);
                if(oDoc.GetByKey(key))
                {
                    if(oDoc.SaveDraftToDocument() != 0)
                        MessageBox.Show(oCompany.GetLastErrorDescription());
                }

Kind Regards,

Diego Lother

0