Skip to Content

Mass deletion of entries inside Draft Documents Table (ODRF) and related tables

I understand that all order drafts are stored inside ODRF table and that row data is stored inside DRF1 table. Using the SAP B1 UI to delete them one by one is a time consuming task. Moreover, I am getting an error message saying draft documents are pending approval and thus cannot be deleted (not sure exactly what is this).

Anyway, Is it safe to delete all those records directly inside the DB i.e. deleting the rows inside ODRF and all related line rows inside DRF1? Thank you.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Oct 09, 2017 at 10:19 AM

    Hi

    check this link.

    Kind regards

    Agustín Marcos Cividanes

    Add comment
    10|10000 characters needed characters exceeded

    • Thanks Agustin Marcos Cividanes I have already managed to put together a DotNET program to connect to SAP using SAPbobsCOM90 and managed to read some order data. Back to my original question, you mean that I need to loop through those order drafts as SBO objects and delete them by some SAPbobsCOM90 built in function. Correct?

  • Oct 09, 2017 at 12:38 PM

    Hi,

    Please make a copy of productive database before deleting draft documents.

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 09, 2017 at 12:46 PM

    Hi

    as Nagarajan says, make a copy of the database before deleting drafts documents.

    Yes, you have to use the SBO object that corresponds to the document draft you want to delete (sales order, delivery,..)

    Kind regards

    Agustín Marcos Cividanes

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 09, 2017 at 01:28 PM

    Hi Waseem,

    You need to do this something as below: (Please change the sample as per your requirement)

    SAPbobsCOM.Recordset oRecSet = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
    oRecSet.DoQuery("Select * From ODRF");
    
    while (oRecSet.EoF == false)
    {
        int DocEntry = Convert.ToInt32(oRecSet.Fields.Item("DocEntry").Value);
        SAPbobsCOM.Documents oDoc = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts);
        oDoc.GetByKey(DocEntry);
    
        int U = oDoc.Remove();
        if (U != 0)
        {
            MessageBox.Show(oCompany.GetLastErrorDescription());
        }
        oRecSet.MoveNext();
    }
    

    Hope it helps!

    Kind regards,

    ANKIT CHAUHAN

    SAP SME Support

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 09, 2017 at 09:53 AM

    Hi

    you have two options:

    1. Deleting every document one by one.

    2. Developing with SDK a program to delete them.

    You cannot delete by SQL statement, you have always to use the SBO objects.

    Kind regards

    Agustín Marcos Cividanes

    Add comment
    10|10000 characters needed characters exceeded