Skip to Content
avatar image
Former Member

ADD INVOICES FROM DI-API USING XML

I NEED TO ADD BILLS BY THE SAP BO SDK USING THE DI-API AND BELIEVE THIS CODE:

// Connects to the SAP Business One company database.

oCompany.Connect();

MessageBox.Show("CONECTADO..!!");

int count = oCompany.GetXMLelementCount("C:\\temp.xml");

SAPbobsCOM.Documents oJE;

oJE = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices);

for (int i = 0; i < count; i++) {

if (oCompany.GetXMLobjectType("C:\\temp.xml", i) == SAPbobsCOM.BoObjectTypes.oInvoices) {

oJE = oCompany.GetBusinessObjectFromXML("C:\\temp.xml", i);

}

}

MessageBox.Show("LEIDO");

int I = oJE.Add();

if (oJE.Add() == 0) {

MessageBox.Show("OK..!!");

}

READING THE XML BUT AT THE TIME OF EXECUTING oJE.Add(), I DO NOT ADD THE INVOICE TO SAP BO, I FLOW IT AS RESULT THE VARIABLE i = 1;

WHAT ERROR CAN I HAVE?

DOES IT HAVE TO DO WITH THE XML?

OR THE CODE?

WHAT STRUCTURE SHOULD I TAKE XML?

PLEASE HELP ='(

THIS IS MY EMAIL jesus.cortez.1991@gmail.com

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Jun 23, 2017 at 07:32 PM

    Hi Jesus,

    Some points:

    1. What is the content of you xml? Could you share?

    2. There is a mistake in your code that Journal Entry is different from Invoice, the your validation is not correct.

    if (oCompany.GetXMLobjectType("C:\\temp.xml", i) == SAPbobsCOM.BoObjectTypes.oInvoices) {
        oJE = oCompany.GetBusinessObjectFromXML("C:\\temp.xml", i);
    }
    

    3. If you have a different value from 0 on your oJE.Add() action, you can try get the error message with the following code:

    oCompany.GetLastErrorDescription();

    4. You shouldn't call twice the method add. After the first time, SDK will clean your object.

    int I = oJE.Add();
    if (I == 0) {
        MessageBox.Show("OK..!!");
    }

    Hope it helps.

    Kind Regards,

    Diego Lother

    Add comment
    10|10000 characters needed characters exceeded