Using to X++ code create and running report

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();
}
posted @ 2010-12-03 17:33  Fandy Xie  Views(282)  Comments(0Edit  收藏  举报