X++ Code below as:
Wrote by Jimmy on DEC.3th 2010
Usinmg X++ Code Created report
static void Jimmy_ReportCodeCreatedRun(Args _args)
{
#AOT
Report areport;
ReportDesign design;
ReportAutoDesignSpecs specs;
ReportSection section;
ReportRun ReportRun;
str reportName = "CodeAutoCreatReport";
tableid custTableId = tablenum(CustTable);
TreeNode reportNode = TreeNode::findNode(#ReportsPath);
;
// Delete the report if it already exists
areport = reportNode.AOTfindChild(reportName);
if (areport)
areport.AOTdelete();
// Build the report
areport = reportNode.AOTadd(reportName);
//Add datasource for report
areport.query().addDataSource(custTableId);
//set up Design
design = areport.addDesign('Design');
design.reportTemplate("InternalList");
design.caption(tableid2PName(tablenum(CustTable)));
specs = design.autoDesignSpecs();
section = specs.addSection(ReportBlockType::Body, custTableId);
section.addControl(custTableId, fieldnum(CustTable, AccountNum));
section.addControl(custTableId, fieldnum(CustTable, Name));
// Now the report will not prompt for user input
areport.interactive(false);
areport.query().interactive(false);
areport.AOTcompile();
ReportRun = ClassFactory.reportRunClass(new Args(reportName));
ReportRun.init();
ReportRun.printJobSettings().suppressScalingMessage(true);//removed Scaling Message
ReportRun.run();
}