Skip to Content

DI API Add Cannot Work

I was trying to add new Item into Purchase Request by using DI API. Didn't occure any error when I run code but it didn't add into table. I checked OPRQ and also PRQ1 tables, both them are empty. Could you tell me where is the wrong? Here is my code:

 SAPbobsCOM.Documents vItem;
                vItem = (SAPbobsCOM.Documents)vCmp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseRequest);
                vItem.Comments = "TEST";
                vItem.DocDate = System.DateTime.Now;
                vItem.DocDueDate = System.DateTime.Now.AddDays(1);               
            catch (Exception ex)

Add comment
10|10000 characters needed characters exceeded

  • You can use this code to print out an error massage and get a good idea of what is wrong:

    int res = vItem.Add();
    if (res != 0)
        int errorCode = 0;
        string errorDesc = "";
        vCmp.GetLastError(out errorCode, out errorDesc);
        Application.SBO_Application.MessageBox($"Inserting Item failed ({errorCode}, {errorDesc}).");
  • Hi Szabolcs,

    Thank you for answer. I tried that you said and I can see now the error mesage. The message: No matching records found (ODBC -2028)

    Do you know why this error happenning?

  • Edy Simon Hatice Kose Ziyali

    Hi Hatice,

    DI API would work the same business logic as the SBO Application.
    Can you generate the Purchase Request in SBO Application by the limited information you passed in your Code?
    For a start, I don't see you pass any itemCode/accountCode in your code.


  • Get RSS Feed

1 Answer

  • Best Answer
    Mar 02, 2018 at 02:37 PM

    Hi Hatice,

    As Edy Simon mentioned on the comments, your code should provide the minimum information to create a purchase request, like we do on the SAP Business One client.

    On SDK help center you are able to see samples of how to add documents with SDK.

    A small sample:

                    SAPbobsCOM.Documents oDoc = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseRequest);
                    oDoc.SendNotification = SAPbobsCOM.BoYesNoEnum.tNO;
                    oDoc.ReqType = 12; //user or 171 as employee
                    oDoc.Requester = "manager";
                    oDoc.RequriedDate = DateTime.Now;
                    oDoc.Lines.ItemCode = "A00001";
                    oDoc.Lines.Quantity = 1;
                    //If you want more itens, call oDoc.Lines.Add(); before provide new items code.
                    if (oDoc.Add() != 0)
                catch (Exception ex)

    Hope it helps.

    Best Regards,

    Diego Lother

    Add comment
    10|10000 characters needed characters exceeded