cancel
Showing results for 
Search instead for 
Did you mean: 

Create JournalVouchers XML File

0 Kudos

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;

Accepted Solutions (1)

Accepted Solutions (1)

former_member185682
Active Contributor
0 Kudos

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

0 Kudos

Hi Diego

Thanks again for your response. Unfortunately it did not work, with the only object that does not work the creation of the xml is with JournalVouchers, I think I'm not doing well. I'm doing several tests as I see them in the sap forums, but I'm not lucky.



Attached several imageserror-1.jpgerror-2.jpg

former_member185682
Active Contributor
0 Kudos

Hi Alvaro,

This error is diferent from the first. You have an error in your code:

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

The correct in this case is :

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

Or

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

Unfortunately JournalVouchers object does not have GetByKey method available.

Kind Regards,

Diego Lother

0 Kudos

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.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hola, has encontrado solución al error?

0 Kudos

Hola, si ya quedó resuelto.

Muchas gracias.

Former Member
0 Kudos

Hello,

Can you please check what is coming in

this.txtKey.Text

Thanks

Engr. Taseeb Saeed

0 Kudos

Hi Tasseb.

error-2.jpgThanks for your answer.

I get the following error (Atached)

regards

Alvaro