How to create a production Entry but keep the lines that populate without adding or changing existing lines

I'm trying to create a production entry.  It works fine if I add lines but if I don't add any lines I get an error message saying I need at least one line.  In the Sage UI you can select a Bill Number and it pre-populates the lines, I'd like to do the same in the BOI.  Any sample code in either VB or C# would be great, thanks!

try
{

object retVal;
string MethodName = string.Empty;
object[] Parameters;
string UIScreen = "";
string lastError = "";

//

// Instantiate a ProvidexX.Script object and initialize with the path to MAS90\Home
using (DispatchObject pvx = new DispatchObject("ProvideX.Script"))
{

pvx.InvokeMethod("Init", @_sagePathDir);


// Instantiate a new Session object and initialize the session
// by setting the user, company, date and module
using (DispatchObject oSS = new DispatchObject(pvx.InvokeMethod("NewObject", "SY_Session")))
{


oSS.InvokeMethod("nSetUser", _sageUser, _sagePass);
retVal = oSS.InvokeMethod("nSetCompany", _sageCompany);
lastError = oSS.InvokeMethod("sLastErrorMsg").ToString();
retVal = oSS.InvokeMethod("nLogon");
lastError = oSS.InvokeMethod("sLastErrorMsg").ToString();
oSS.InvokeMethod("nSetDate", "A/R", DateTime.Now.Year.ToString("D4") + DateTime.Now.Month.ToString("D2") + DateTime.Now.Day.ToString("D2"));
oSS.InvokeMethod("nSetModule", "A/R");

int TaskID = (int)oSS.InvokeMethod("nLookupTask", "BM_Production_UI");
retVal = oSS.InvokeMethod("nSetProgram", TaskID);


using (DispatchObject pe = new DispatchObject(pvx.InvokeMethod("NewObject", "BM_Production_bus", oSS.GetObject())))
{
try
{
string prodEntryNo = "";
object[] arrResults = new object[] { prodEntryNo };
object[] useBatch = new object[] { true };
object[] batchName = new object[] { "" };
string num = "";
string BatchPrivateField = "N";
string BatchComment = "Test Production Entry from Code";
object[] batchNoObject = new object[] { num, BatchPrivateField, BatchComment };

var p = Convert.ToInt32(pe.GetProperty("nBatchEnabled"));
if (p > 0)
{

pe.InvokeMethodByRef("nSelectNewBatch", batchNoObject);
pe.InvokeMethod("nSetValue", batchNoObject);
pe.InvokeMethod("nSetValue", "BatchNo$", batchNoObject[0].ToString());
}

retVal = pe.InvokeMethodByRef("nGetNextProductionNo", arrResults);
lastError = pe.InvokeMethod("sLastErrorMsg").ToString();
prodEntryNo = arrResults[0].ToString();

retVal = (int)pe.InvokeMethod("nSetKey", prodEntryNo);
lastError = pe.InvokeMethod("sLastErrorMsg").ToString();

pe.InvokeMethod("nSetValue", "ProductionDate$", DateTime.Now.Year.ToString("D4") + DateTime.Now.Month.ToString("D2") + DateTime.Now.Day.ToString("D2"));
retVal= (int)pe.InvokeMethod("nSetValue", "BillNo$", order.ItemCode);
lastError = pe.InvokeMethod("sLastErrorMsg").ToString();
if ((int)retVal == 0) order.Error = lastError;
pe.InvokeMethod("nSetValue", "Revision$", order.Revision);
pe.InvokeMethod("nSetValue", "EffectiveDate$", DateTime.Now.Year.ToString("D4") + DateTime.Now.Month.ToString("D2") + DateTime.Now.Day.ToString("D2"));
pe.InvokeMethod("nSetValue", "ParentWarehouseCode$", order.ParentWhse);
pe.InvokeMethod("nSetValue", "DefaultComponentWhseCode$", order.ComponentWhse);
pe.InvokeMethod("nSetValue", "ExplodeSubAssemblies$", "Y");
pe.InvokeMethod("nSetValue", "ProductionQuantity", order.Qty);

//using (DispatchObject oLines = new DispatchObject(pe.GetProperty("oLines")))
//{
// retVal = (int)oLines.InvokeMethod("nAddLine");
// lastError = oLines.InvokeMethod("sLastErrorMsg").ToString();
// retVal = oLines.InvokeMethod("nSetValue", "ProductionNo$", prodEntryNo);
// lastError = oLines.InvokeMethod("sLastErrorMsg").ToString();

// retVal = oLines.InvokeMethod("nSetValue", "ComponentItemCode$", "CDROM-0002X");
// lastError = oLines.InvokeMethod("sLastErrorMsg").ToString();

// retVal = oLines.InvokeMethod("nSetValue", "QuantityPerBill", 1);
// lastError = oLines.InvokeMethod("sLastErrorMsg").ToString();

// retVal = oLines.InvokeMethod("nSetValue", "ExtendedQuantity", 1);
// lastError = oLines.InvokeMethod("sLastErrorMsg").ToString();

// //Write Line
// retVal = oLines.InvokeMethod("nWrite");
//lastError = oLines.InvokeMethod("sLastErrorMsg").ToString();


//}

retVal = pe.InvokeMethod("nWrite");
lastError = pe.InvokeMethod("sLastErrorMsg").ToString();

if((int)retVal!=0)
{
//Success
order.SentToSage = DateTime.Now;
order.ProductionEntryNo = prodEntryNo;
order.BatchNo = batchNoObject[0].ToString();
}
else
{
//Failure
order.Error = order.Error+ ' '+ lastError;
order.ErrorDate=DateTime.Now;
}
}
catch (Exception ex)
{

}
finally
{
//Dispose Sage BOI Dispatch Object in case of error so PVXCOM isn't sitting open in Task Manager
retVal = pe.InvokeMethod("nClear");
lastError = pe.InvokeMethod("sLastErrorMsg").ToString();
oSS.Dispose();

}

}

oSS.Dispose();

}

}

return order;
}

catch (Exception ex)
{
order.Error = ex.Message;
return order;
}