on 05-13-2015 10:08 AM
Hi!
I have problem with adding new Correction Invoice using DI Api. I'm trying this code:
Documents srcInvoice = SAPUtils.Instance.Company.GetBusinessObject(BoObjectTypes.oInvoices) as Documents;
srcInvoice.GetByKey(invoiceDocNumber);
Documents invoice = SAPUtils.Instance.Company.GetBusinessObject(BoObjectTypes.oCorrectionInvoice) as Documents;
invoice.CardCode = srcInvoice.CardCode;
invoice.CardName = srcInvoice.CardName;
invoice.HandWritten = BoYesNoEnum.tNO;
invoice.DocDate = new DateTime(2013, 3, 20);
invoice.DocType = BoDocumentTypes.dDocument_Items;
invoice.Series = 317;
invoice.Comments = "Invalid quantity.";
invoice.VatDate = new DateTime(2013, 1, 20);
//items
IDocument_Lines lines = invoice.Lines;
int lineNo = 0;
IDocument_Lines srcLines = srcInvoice.Lines;
for (int i = 0; i < srcLines.Count; i++)
{
srcLines.SetCurrentLine(i);
if (lineNo > 0)
lines.Add();
lines.SetCurrentLine(lineNo++);
lines.ItemCode = srcLines.ItemCode;
lines.ItemDescription = srcLines.ItemDescription;
lines.Price = srcLines.Price;
lines.Quantity = 3;
lines.BaseEntry = invoiceDocNumber;
lines.BaseLine = i;
lines.CorrectionInvoiceItem = BoCorInvItemStatus.ciis_ShouldBe;
lines.LineStatus = BoStatus.bost_Close;
}
for (int i = 0; i < srcLines.Count; i++)
{
srcLines.SetCurrentLine(i);
if (lineNo > 0)
lines.Add();
lines.SetCurrentLine(lineNo++);
lines.ItemCode = srcLines.ItemCode;
lines.ItemDescription = srcLines.ItemDescription;
lines.Price = srcLines.Price;
lines.Quantity = srcLines.Quantity;
lines.BaseEntry = invoiceDocNumber;
lines.BaseLine = i;
lines.CorrectionInvoiceItem = BoCorInvItemStatus.ciis_Was;
lines.LineStatus = BoStatus.bost_Close;
}
int result = invoice.Add();
Console.WriteLine(result);
if (result == 0)
Console.WriteLine("Invoice added");
But when it comes to invoice.Add() program suddenly crashes. I get info that vshost32.exe has stopped working. What I am doing wrong?
Hi
Thank you for your answer. I found solution myself .
-Ewa
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ewa
Each SCN forum, under the Overview tab, describes the products it is designed for. In this case:
Based on the above, I suspect you posted your query in an incorrect SCN Space. Unfortunately, you do not mention what SAP product you are working with, so I am not able to recommend a Space for you.
- Ludek
SCN Moderator
Senior Support Engineer AGS Product Support, Global Support Center Canada
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.