Not able to add G/L account in Purchase Order

SOLVED

Hi

I am trying to create purchase order in sage100c v2021 using PO script but getting error "G/L account is required" while adding item line
this is my script in c# and i am referring the table "PO_PurchaseOrder_bus" for PO fields

//Purchase Order
int taskID = (int)oSS.InvokeMethod("nLookupTask", "PO_PurchaseOrder_ui");
oSS.InvokeMethod("nSetProgram", TaskID);
object retVal = 0;

using (DispatchObject po_order = new DispatchObject(pvx.InvokeMethod("NewObject", "PO_PurchaseOrder_bus", oSS.GetObject())))
{
try
{
retVal = po_order.InvokeMethod("nSetValue", "PurchaseOrderNo$", "12345");
retVal = po_order.InvokeMethod("nSetValue", "OrderType$", "S");
retVal = po_order.InvokeMethod("nSetKey");

retVal = (int)po_order.InvokeMethod("nSetValue", "APDivisionNo$", "00");

retVal = po_order.InvokeMethod("nSetValue", "VendorNo$", "Alen");

retVal = po_order.InvokeMethod("nSetValue", "TaxSchedule$", "NONTAX");

// Add a line
retVal = po_order.InvokeMethod("nAddLine");

using (DispatchObject oLines = new DispatchObject(po_order.GetProperty("oLines")))
{


retVal = oLines.InvokeMethod("nAddLine");

retVal = oLines.InvokeMethod("nSetValue", "ItemCode$", miscellaneousItem);

retVal = oLines.InvokeMethod("nWrite");   // it sets to "0" and i am getting error here "G/L account is required"

if (retVal.ToString() == "0")
{
object errorMsg = oLines.GetProperty("sLastErrorMsg");
Service1.WriteToLogFile(errorMsg.ToString());
Console.Read();
}
}
else
{
Service1.WriteToLogFile("Item line added successfully");
oLines.Dispose();
}
}

//Write the po order
retVal = po_order.InvokeMethod("nWrite");
if (retVal.ToString() == "0")
{
object errorMsg = po_order.GetProperty("sLastErrorMsg");
Service1.WriteToLogFile(errorMsg.ToString());
Console.Read();
}
else
{
Service1.WriteToLogFile("Purchase Order created successfully " );
}
}
catch (Exception ex)
{
object errorMsg = po_order.GetProperty("sLastErrorMsg");
Service1.WriteToLogFile(" Error while creating purchase order :- " + errorMsg.ToString());
Service1.WriteToLogFile(ex.Message);
Console.Read();
}
finally
{
po_order.Dispose();
}
}

can anyone help me out which field i can use to add G/L account in item line and where?

Thank You

Parents Reply Children
No Data