Skip to Content

Create JournalVouchers XML File

Hi experts.

I have this code that generates sap xml files, whenever I need to create an xml file of a new transaction to check the structure of the file I simply add a new case and that's it, but with the (BoObjectTypes.oJournalVouchers) there is no way that Work for me. The error show me:

The error shows me:

Attempt to read or write to protected memory. Often this indicates that there is another memory damaged.error-journalvouchers.jpg



Below the code.

{
case 0:
{
Documents businessObject = (Documents) this.oCompany.GetBusinessObject(BoObjectTypes.oInvoices);
businessObject.GetByKey(int.Parse(this.txtKey.Text));
businessObject.SaveXML(ref fileName);
break;
}
case 1:
{
Documents documents2 = (Documents) this.oCompany.GetBusinessObject(BoObjectTypes.oCreditNotes);
documents2.GetByKey(int.Parse(this.txtKey.Text));
documents2.SaveXML(ref fileName);
break;
}
case 2:
{
Payments payments = (Payments) this.oCompany.GetBusinessObject(BoObjectTypes.oIncomingPayments);
payments.GetByKey(int.Parse(this.txtKey.Text));
payments.SaveXML(ref fileName);
break;
}
case 3:
{
JournalVouchers journalVouchers = (JournalVouchers)this.oCompany.GetBusinessObject(BoObjectTypes.oJournalVouchers);
journalVouchers.JournalEntries.GetByKey(int.Parse(this.txtKey.Text));
journalVouchers.JournalEntries.SaveXML(ref fileName);

break;
}
case 4:
{
BusinessPartners partners = (BusinessPartners) this.oCompany.GetBusinessObject(BoObjectTypes.oBusinessPartners);
partners.GetByKey(this.txtKey.Text);
partners.SaveXML(ref fileName);
break;
}
case 5:
{
Documents documents3 = (Documents) this.oCompany.GetBusinessObject(BoObjectTypes.oQuotations);
documents3.GetByKey(int.Parse(this.txtKey.Text));
documents3.SaveXML(ref fileName);
break;
}
case 6:
{
StockTransfer StockTransfer = (StockTransfer)this.oCompany.GetBusinessObject(BoObjectTypes.oStockTransfer);
StockTransfer.GetByKey(int.Parse(this.txtKey.Text));
StockTransfer.SaveXML(ref fileName);
break;
}
case 7:
{
Documents InventoryGenExit = (Documents)this.oCompany.GetBusinessObject(BoObjectTypes.oInventoryGenExit);
InventoryGenExit.GetByKey(int.Parse(this.txtKey.Text));
InventoryGenExit.SaveXML(ref fileName);
break;

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Mar 03, 2017 at 12:41 AM

    Hi Alvaro,

    This is a common error and can occurs in any part of code of DI API. To solve this issue I suggest the following solutions. Try each solution and check if solve the problem

    1. Going to the %temp% folder and removing the SM_OBS_DLL folder

    2. Reinstall the DI-API

    3. Reinstall the client

    Hope it helps.

    Kind Regards,

    Diego Lother

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Diego.

      regarding:

      JournaEntries oJournalEntries = (JournalEntries) this.oCompany.GetBusinessObject (BoObjectTypes.oJournalEntries);

      Works perfect, as you can see in the attachments I get you the xml.

      But with:

      JournalVouchers oJournalVouchers = (JournalVouchers) this.oCompany.GetBusinessObject (BoObjectTypes.oJournalVouchers);

      Actually I can not get the getbykey, the only way is as I show it below:

      JournalVouchers oJournalVouchers = (JournalVouchers) this.oCompany.GetBusinessObject (BoObjectTypes.oJournalVouchers);
      OJournalVouchers.JournalEntries.GetByKey (int.Parse (this.txtKey.Text));
      OJournalVouchers.JournalEntries.SaveXML (ref fileName);

      But I only get the memory error, which previously you had already indicated how to solve it but it did not work.

      What can i do in this case? how can i get the xml file?option-1.jpgdiegoxml.txterror-2.jpg



      Attached error.

      diegoxml.txt (8.1 kB)
      option-1.jpg (94.4 kB)
      error-2.jpg (102.0 kB)
  • avatar image
    Former Member
    Mar 06, 2017 at 05:07 AM

    Hello,

    Can you please check what is coming in

    this.txtKey.Text

    Thanks

    Engr. Taseeb Saeed

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 31, 2017 at 05:40 PM

    Hola, has encontrado solución al error?

    Add comment
    10|10000 characters needed characters exceeded