Skip to Content
0

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

Oct 09, 2017 at 09:31 AM

100

avatar image

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.

SQL
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

5 Answers

Agustin Marcos Cividanes Oct 09, 2017 at 10:19 AM
1

Hi

check this link.

Kind regards

Agustín Marcos Cividanes

Show 1 Share
10 |10000 characters needed characters left 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?

0
Nagarajan K Oct 09, 2017 at 12:38 PM
1

Hi,

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

Share
10 |10000 characters needed characters left characters exceeded
Agustin Marcos Cividanes Oct 09, 2017 at 12:46 PM
1

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

Share
10 |10000 characters needed characters left characters exceeded
ANKIT CHAUHAN
Oct 09, 2017 at 01:28 PM
1

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

Share
10 |10000 characters needed characters left characters exceeded
Agustin Marcos Cividanes Oct 09, 2017 at 09:53 AM
0

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

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

Would you kindly refer me to the SDK reference? Is it avaliable online?

0