Batch job to print reports overnigt

Hello world[:D]
“Problem is, this info is only available to Ugu (Municipality), once the query is run manually, against one Purchase Requisition at a time. There is no report on it, no history on it.
So you must create a batch job, that does a Commitment check against all open PR’s; saves the info for every PR to a table, then you must build a report to query that table.
The batch job must run every night and populate the table automatically.”

Please help.

Thank you in advance

Sinoyolo

Hi Sonoyolo,

Not sure what you are looking for exactly. Please can you clarify your query?

Hi sinoyolo,

I’m not sure about your requirement but, to create a batch job, you can create a class that extends runBaseBatch class ( see the tutorial_RunBaseBatchClass in AOT), then in the run Method, you can create a query that populates your table, do this step first, for the report, I did something similar, I had to generate salesQuotation pdf files, here’s a sample code, I call it in the run() method of my class:

SalesQuotationTable SalesQuotation;
ReportRun report;
str filename,path;
;
path = “\\yourPath\Yourdirectory\”;

while select SalesQuotation where blablabla
{
filename = strfmt("%1%2",SalesQuotation.QuotationId,".pdf");

report = new ReportRun(new Args(ReportStr(MyReport)));
report.query().interactive(false);
report.report().interactive(false);
report.args().caller(null);

report.args().parm(SalesQuotation.QuotationId);

report.printJobSettings().setTarget(PrintMedium::File);//Print into a file
report.printJobSettings().format(PrintFormat::PDF);//file format = pdf
report.printJobSettings().warnIfFileExists(false);
report.printJobSettings().fileName(strfmt("%1%2",path,filename));
report.run();
}

then you’ll probably have to deal with security problems or bugs batch specific, try first to create and populate your table with batch job when it’s OK, mail me if you have problems with the report generation, I’ll try to help

Regards,

Thomas

Hi Harish

Basically what I’m requested to do is to record all commitments on Budget votes be kept. There must be a report available. Do a batch that will calculate all commitments in the system against all budget votes and this must be done daily.

I’m not sure if now you can get it, but if not please tell I’ll find another way to explain it.

Thank you

Sinoyolo

Hi Thomas

I’m quite sure this is what I need. I’ll do just that.

Thank you for the replies.

Sinoyolo

I am using Ax2012 and I am getting error when trying to run Morphx report using batch process. I am getting error in Line 16 as shown below:

//////////////////////////////////////

4filename =

strfmt("%1%2",“ABc”,".pdf");

report =

new ReportRun(new Args(ReportStr(ReportName))); //Line 16

report.query().interactive(

false);

report.report().interactive(

false);

report.args().caller(

null);

//report.args().parm(SalesQuotation.QuotationId);

report.printJobSettings().setTarget(PrintMedium::File);

//Print into a file

report.printJobSettings().format(PrintFormat::PDF);

//file format = pdf

report.printJobSettings().warnIfFileExists(

false);

report.printJobSettings().fileName(

strfmt("%1%2",path,filename));

report.run();

NOw my error is : Line 1 :“Object ‘ReportRun’ could not be created”

and Line 2: "Microsoft.Dynamics.Ax.Xpp.InternalException: Exception of type ‘Microsoft.Dynamics.Ax.Xpp.InternalException’ was thrown.

at Microsoft.Dynamics.Ax.MSIL.cqlClassIL.create(Int32 classId, Object[] parameters, Type[] types, Object[] varargs, Type[] varargsTypes, Object ILObject)

at Microsoft.Dynamics.Ax.Xpp.XppObjectBase.createKernelClass(Object[] parameters, Type[] paramTypes, Object[] varargs)

at Dynamics.Ax.Application.ReportRun.new(Object argsOrReportOrContainer)

at Dynamics.Ax.Application.ReportRun…ctor(Object argsOrReportOrContainer)

at Dynamics.Ax.Application.dev_IRDETOBP_SuspActivation.Run() in dev_IRDETOBP_SuspActivation.run.xpp:line 16

at Dynamics.Ax.Application.BatchRun.runJobStatic(Int64 batchId) in BatchRun.runJobStatic.xpp:line 50

at BatchRun::runJobStatic(Object[] )

at Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.MakeStaticCall(Type type, String MethodName, Object[] parameters)

at BatchIL.taskThreadEntry(Object threadArg)"

////////////////////////////////////////////////////////////

please reply asap.