cancel
Showing results for 
Search instead for 
Did you mean: 

"Update quantity in purchase orders" ???

Former Member
0 Kudos

Hi,

at the moment I'm developing an interface solution for a customer, where cash receipts from a POS are to be transferred into SAP Business One, Version 6.5.

For this purpose I'm using the SDK.

For another customer, using SAP Business One 6.2 the following code did work perfectly:

oI is an oInvoice.

oI.Series = 0;

oI.CardCode = "K00001"; // Anonymous customer

oI.HandWritten = SAPbobsCOM.BoYesNoEnum.tNO;

.

.

.

then, I create the lines:

foreach (DataRow row in tableLines)

{

oI.Lines.Add();

oI.Lines.ItemCode = row["Number"].ToString();

// etc... (ItemDescription, PriceAfterVAT, Quantity and Currency are set as well)

}

oI.DocTotal = double.Parse(row["Total"].ToString());

if (oI.Add() != 0)

{

// ERROR: -5002 / "Update quantity in purchase order?"

}

In 6.2 this code works, for another company, perfectly, they are transferring about 2000 lines per day without problems.

It also does not matter if I use oQuotation instead of oInvoice - the same error occurs.

Is this a bug in 6.5 or am I doing something wrong?

Thanks

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Two things to try:

#1. The first line is already instantiated for you in a 6.5 Document. Not sure if this was the case in 6.2. The result is that you always have one too many Lines in your existing code. You could try something like this instead:

int index = 0;

foreach (DataRow row in tableLines){

if(index >= oI.Lines.Count){

oI.Lines.Add();

}

oI.Line.SetCurrentLine(index);

oI.Lines.ItemCode = row["Number"].ToString();

// etc... (ItemDescription, PriceAfterVAT, Quantity and Currency are set as well)

index++;

}

#2. If the code above is in a loop, make sure your oI is newly instantiated for each loop. If you re-use the object, I've seen trouble where Lines from a previous loop linger and create big trouble in the next.

Hope this helps.

Former Member
0 Kudos

This works perfectly for me - thank you very much, Corbin.