Skip to Content
avatar image
Former Member

Closing a delivery note Draft with SDK

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

Add comment
10|10000 characters needed 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

  • Get RSS Feed

5 Answers

  • Feb 17, 2017 at 02:51 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 20, 2017 at 01:59 AM

    Hi Marco,

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

    Regards

    Edy

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 20, 2017 at 08:51 AM

    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
    
    
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 20, 2017 at 08:51 AM

    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()
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 20, 2017 at 09:08 AM

    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 ? !

    Add comment
    10|10000 characters needed 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