Thanks for the information Elliott... Awhile back I had made a change to a piece of code to look for the != 1, and have been copy/pasting that error since. But, for anyone looking to quick print picking sheets, from C#, the process turned out much simpler after a little bit more research. Again, for my needs, I still wanted to initiate the UI. There are some real good examples on how to bypass the UI if you wanted to. Here is what our final function looked like: private void PrintPickingSheet(string SalesOrderNo) { object retVal; string MethodName = string.Empty; // Instantiate a ProvidexX.Script object and initialize with the path to MAS90\Home using (DispatchObject pvx = new DispatchObject("ProvideX.Script")) { pvx.InvokeMethod("Init", @"\\srvsage100adv\Sage\Sage 100 Advanced ERP\MAS90\Home"); // 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", UID, PWD); oSS.InvokeMethod("nSetCompany", CompanyCode); oSS.InvokeMethod("nLogon"); oSS.InvokeMethod("nSetDate", "S/O", DateTime.Now.Year.ToString("D4") + DateTime.Now.Month.ToString("D2") + DateTime.Now.Day.ToString("D2")); oSS.InvokeMethod("nSetModule", "S/O"); //Set Program to SO_PickingSheetPrinting int TaskID = (int)oSS.InvokeMethod("nLookupTask", "SO_PickingSheetQuickPrint_ui"); retVal = oSS.InvokeMethod("nSetProgram", TaskID); using (DispatchObject SO_PickingSheetPrinting_ui = new DispatchObject(pvx.InvokeMethod("NewObject", "SO_PickingSheetQuickPrint_UI", oSS.GetObject()))) { MethodName = "nInitiateUI"; retVal = oSS.InvokeMethod(MethodName); using (DispatchObject SY_UI = new DispatchObject(oSS.GetProperty("oUI"))) { MethodName = "nInitCustomizer"; retVal = SY_UI.InvokeMethod(MethodName); retVal = SO_PickingSheetPrinting_ui.SetProperty("sQuickPrint", SalesOrderNo); MethodName = "nProcess"; retVal = SO_PickingSheetPrinting_ui.InvokeMethod(MethodName); if ((int)retVal == 0) { HandleError(retVal, MethodName, new object[] { "" }, SO_PickingSheetPrinting_ui.GetProperty("sLastErrorMsg")); } } } } } }
↧