Looking at your code my inference is the object with the IReportLoaderService and IReportRenderer interface decleration never properly gets initialized with PXGraph.CreateInstance<...> before calling save method.
new KWProcessWorkCenterOpenJobReports().save(list, aIsMassProcess);
The following code snippet will generate a report from the given paramaters provided and then save the file within the Acumatica system, though it can be further emailed out as mentioned in your original prompt.
using PX.Data;
using PX.Objects.AR;
using PX.Reports;
using PX.Reports.Controls;
using PX.Reports.Data;
using PX.SM;
using System.Collections.Generic;
using MailMessage = PX.Reports.Mail.Message;
namespace StackOverflow
{
public class EmailReportProc : PXGraph<EmailReportProc>
{
#region Constructor
public EmailReportProc()
{
Documents.SetProcessDelegate(generateAcumaticaReports);
}
#endregion
#region Properties
[InjectDependency]
protected IReportLoaderService ReportLoader { get; set; }
[InjectDependency]
protected IReportDataBinder ReportDataBinder { get; set; }
#endregion
#region Views
public PXCancel<ARInvoice> Cancel;
public PXProcessing<ARInvoice, Where<ARInvoice.status, Equal<ARDocStatus.pendingEmail>>> Documents;
#endregion
#region Methods
private static void generateAcumaticaReports(List<ARInvoice> Documents)
{
//Initialize new graph instance for use within static processing method.
EmailReportProc graph = PXGraph.CreateInstance<EmailReportProc>();
foreach (ARInvoice document in Documents)
{
//Paramaters for report
Dictionary<string, string> parameters = new Dictionary<string, string>
{
{ "ARInvoice.DocType", document.DocType },
{ "ARInvoice.RefNbr", document.RefNbr }
};
//Load report - ReportID must be valid sitemap entry in system
Report report = graph.ReportLoader.LoadReport("AR622000", null);
//Initialize the parameters for the report
graph.ReportLoader.InitDefaultReportParameters(report, parameters);
ReportNode reportNode = graph.ReportDataBinder.ProcessReportDataBinding(report);
//Generate PDF Report and creates Acumatica file.
FileInfo fileInfo = new FileInfo(reportNode.ExportFileName + ".pdf", null, MailMessage.GenerateReport(reportNode, RenderType.FilterPdf)[0]);
UploadFileMaintenance uploadFileMaintenance = PXGraph.CreateInstance<UploadFileMaintenance>();
//Save Generated file into system
_ = uploadFileMaintenance.SaveFile(fileInfo);
}
}
#endregion
}
}