Skip to Content
avatar image
Former Member

Need an example for create draft document thru DI API

Dear All,

I need to create a draft document ( sales Invoice ), data shall be saved into table ODRF and DRF1, I had tried modify given sample code in SDK.

Now the question is : Suppose there are 10 items on the Invoice, after data insertion, there should be 10 new records in table DRF1, all with same document entry and line number ( ranging from 0 to 9 ), appreciated that if someone could provide me some sample codes, thank you !

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Sep 13, 2017 at 08:31 AM

    Hi Scott,

    You need to use it following way:

    SAPbobsCOM.Documents oDocDraftSalesInvoice = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts);
    oDocDraftSalesInvoice.DocObjectCode = SAPbobsCOM.BoObjectTypes.oInvoices;
    //Setting up the data for Header
    oDocDraftSalesInvoice.DocDueDate = DateTime.Today;
    oDocDraftSalesInvoice.CardCode = CardCode;
    //Setting up the data for Lines
    oDocDraftSalesInvoice.Lines.ItemCode = ItemCode;
    oDocDraftSalesInvoice.Lines.Quantity = 1;
    // This will add the second line. You need to repeat this process for 10 lines.
    oDocDraftSalesInvoice.Lines.ItemCode = ItemCode;
    oDocDraftSalesInvoice.Lines.Quantity = 2;
    //This will attempt to add the document.
    int AddDraftSalesInvoice = oDocDraftSalesInvoice.Add();
    if (AddDraftSalesInvoice != 0)
    else if (AddDraftSalesInvoice == 0)
        MessageBox.Show("Document added successfully!");

    Hope it helps!

    Kind regards,


    SAP SME Support

    Add comment
    10|10000 characters needed characters exceeded