This Invoice has no lines and has zero total amounts - while using batch option

Hi All,

I am trying to import the Sales invoice into Sage 100, using Business object interface. using below code.

using(DispatchObject oARCustomerEntry = new DispatchObject())
{
object retVal = 0;

object[] nextSalesOrderNumber = new object[] { "InvoiceNo$" };
oARCustomerEntry.InvokeMethodByRef("nGetNextInvoiceNo", nextSalesOrderNumber);
retVal = oARCustomerEntry.InvokeMethodByRef("nSetKeyValue", new object[] { "InvoiceNo$", nextSalesOrderNumber[0].ToString() });
retVal = oARCustomerEntry.InvokeMethod("nSetKey");
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "ARDivisionNo$", "00" });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "CustomerPONo$", CustomerPONumber });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "CustomerNo$", "TES001" });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "BatchNo$", "TEST2" });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "SalesOrderNo$", "0012474" });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "BillToName$", AccountName });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "TermsCode$", Terms });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "OrderDate$", OrderStartDate });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "ShipVia$", ShipVia });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "TaxSchedule$", "NONTAX" });

string PRODUCT_CODE__C = "";
string QUANTITY = "";
string UNITPRICE = "";
DispatchObject sales_order_line = new DispatchObject(oARCustomerEntry.GetProperty("oLines"));
int Count = 1;
foreach (var urlElement in generalElement.Elements("OrderItems_type"))
{
if (urlElement.Element("OrderItems_") != null)
{
PRODUCT_CODE__C = urlElement.Element("OrderItems_").Value;
}
if (urlElement.Element("OrderItems_Quantity") != null)
{
QUANTITY = urlElement.Element("OrderItems_Quantity").Value;
}
if (urlElement.Element("OrderItems_UnitPrice") != null)
{
UNITPRICE = urlElement.Element("OrderItems_UnitPrice").Value;
}
string line = "";
if (Count.ToString().Length == 1)
{
line = "00000" + Count.ToString();
}
else if (Count.ToString().Length == 2)
{
line = "0000" + Count.ToString();
}
else if (Count.ToString().Length == 3)
{
line = "000" + Count.ToString();
}

object EditKey = sales_order_line.InvokeMethod("sGetEditKey", line);
retVal = sales_order_line.InvokeMethod("nEditLine", EditKey);

sales_order_line.InvokeMethod("nSetValue", "ItemCode$", UnescapeXML(PRODUCT_CODE__C));
sales_order_line.InvokeMethod("nSetValue", "UnitPrice", Convert.ToDecimal(UNITPRICE));
int qty = Convert.ToInt32(Convert.ToDecimal(QUANTITY));
sales_order_line.InvokeMethod("nSetValue", "QuantityOrdered", qty);

sales_order_line.InvokeMethod("nWrite");
Count++;
}

retVal = oARCustomerEntry.InvokeMethod("nWrite");
if (retVal.ToString() == "0")
{
object errorMsg = oARCustomerEntry.GetProperty("sLastErrorMsg");
Message = "Invoice # " + nextSalesOrderNumber[0].ToString() + " has failed to insert in Sage. - " + errorMsg.ToString();
ReturnValue = "1";
btCompleted = false;
Status = "Failed";
}
else
{
Message = "Invoice # " + nextSalesOrderNumber[0].ToString() + " has successfully inserted into Sage.";
ReturnValue = "1";
btCompleted = true;
Status = nextSalesOrderNumber[0].ToString();
}
}
}

The error is "This Invoice has no lines and has zero total amounts".

I test this code in my local it working good without using batch number step. but it is not working on the client machine with the Batch number procedure. Can any one have any idea to resolve this issue? Or give me some hint to try to solve it.

Thanks,

SF