Skip to Content
0

Create JournalVouchers XML File

Mar 02, 2017 at 10:52 PM

115

avatar image
Former Member

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;

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
DIEGO LOTHER Mar 03, 2017 at 12:41 AM
0

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

Show 3 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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

error-1.jpg (140.1 kB)
error-2.jpg (120.6 kB)
0

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
Former Member
DIEGO LOTHER

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)
0
avatar image
Former Member Mar 06, 2017 at 05:07 AM
0

Hello,

Can you please check what is coming in

this.txtKey.Text

Thanks

Engr. Taseeb Saeed

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Tasseb.

error-2.jpgThanks for your answer.

I get the following error (Atached)

regards

Alvaro

error-2.jpg (102.0 kB)
0
avatar image
Former Member Jul 31, 2017 at 05:40 PM
0

Hola, has encontrado solución al error?

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hola, si ya quedó resuelto.

Muchas gracias.

0