Sage 100 ERP Version 5.00.8.0
The following code fails at the call to nProcessReport returning 0 and LastErrorMessage is blank.
using (DispatchObject pvx = new DispatchObject("ProvideX.Script"))
{
pvx.InvokeMethod("Init", @"C:\Sage\Sage 100 Advanced ERP\MAS90");
using (DispatchObject oSS = new DispatchObject(pvx.InvokeMethod("NewObject", "SY_Session")))
{
retVal = (int)oSS.InvokeMethod("nSetUser", "admin", "admin@123");
retVal = (int)oSS.InvokeMethod("nSetCompany", "ABC");
retVal = (int)oSS.InvokeMethod("nSetDate", new object[] { "A/P", string.Format("{0:yyyyMMdd}", DateTime.Now.Date) });
retVal = (int)oSS.InvokeMethod("nSetModule", "A/P");
int iTaskID = (int)oSS.InvokeMethod("nLookupTask", new object[] { "AP_InvoiceRegister_ui" });
retVal = (int)oSS.InvokeMethod("nSetProgram", iTaskID);
using (DispatchObject upd = new DispatchObject(pvx.InvokeMethod("NewObject", new object[] { "AP_InvoiceRegister_upd", oSS.GetObject() })))
{
//retVal = (int)upd.InvokeMethodByRef("nSelectBatch", new object[] { "" });
retVal = (int)upd.InvokeMethod("nSetPostingDate", "20150820");
retVal = (int)upd.InvokeMethod("nProcessReport", "PRINT");
if (retVal == 0)
{
string msg = (string)upd.GetProperty("sLastErrorMsg");
throw new Exception("Error in nProcessReport: " + msg);
}
retVal = (int)upd.InvokeMethod("nUpdate", null);
retVal = (int)upd.InvokeMethod("nClear", null);
}
}