CustAccountStatementExt
演示如何向 Customer account statement report 添加新字段
1.添加新字段
主临时表是 CustAccountStatementExtTmp,右键单击并创建扩展;我将添加一个新的字符串字段 MaxTxT。
2. 复制这个报表
重命名为:CustAccountStatementExt
3.修改报告设计
右键单击报表数据集并选择恢复以刷新新字段,打开报表设计器并将该字段添加到表中
4. 创建一个新的扩展类来扩展标准报表Controller class
class CustAccountStatementExtControllerExtextends CustAccountStatementExtController { //Add construct public static CustAccountStatementExtControllerExtconstruct() { return new CustAccountStatementExtControllerExt(); } public static void main(Args _args) { SrsPrintMgmtFormLetterController controller = new CustAccountStatementExtControllerExt(); controller.parmReportName(PrintMgmtDocType::construct(PrintMgmtDocumentType::CustAccountStatement).getDefaultReportFormat()); controller.parmArgs(_args); CustAccountStatementExtControllerExt::startControllerOperation(controller, _args); } protected static void startControllerOperation(SrsPrintMgmtFormLetterController _controller, Args _args) { _controller.startOperation(); } }
可选方法,确定报表的默认设计,有些报表不使用
protected void outputReport() { SRSCatalogItemName reportDesign; reportDesign = ssrsReportStr(CustAccountStatementExt,Report); this.parmReportName(reportDesign); this.parmReportContract().parmReportName(reportDesign); formletterReport.parmReportRun().settingDetail().parmReportFormatName(reportDesign); super(); }
5. 创建新的report handler class
我们有两种不同的方法来填充报表处理程序类中的数据:
- 添加临时表插入事件,逐行计算。转到 AOT 中的 CustAccountStatementExtTmp,展开事件节点,然后复制事件处理程序方法。
- 添加数据处理post-handler,插入对标准解决方案的结果集使用单次传递的操作。
class MaxCustAccountStatementExtHandler { [DataEventHandlerAttribute(tableStr(CustAccountStatementExtTmp), DataEventType::Inserting)] public static void CustAccountStatementExtTmpInsertEvent(Common c, DataEventArgs e) { CustAccountStatementExtTmp tempTable = c; CustGroup custGroup; select * from tempTable where tempTable.CustGroup == custGroup.CustGroup; tempTable.MaxTxT = custGroup.Description; } }
class MaxCustAccountStatementExtHandler { [PostHandlerFor(classStr(CustAccountStatementExtDP), methodstr(CustAccountStatementExtDP, processReport))] public static void TmpTablePostHandler(XppPrePostArgs arguments) { CustAccountStatementExtDP dpInstance = arguments.getThis() as CustAccountStatementExtDP; CustAccountStatementExtTmp tmpTable = dpInstance.getCustAccountStatementExtTmp(); CustGroup custGroup; ttsbegin; while select forUpdate tmpTable { select * from tempTable where tempTable.CustGroup == custGroup.CustGroup; tempTable.MaxTxT = custGroup.Description; tmpTable.update(); } ttscommit; } }
6. 添加delegate handler
在此示例中,使用以下代码扩展 PrintMgtDocTypeHandlerExt 类中的 getDefaultReportFormatDelegate 方法。
class PrintMgtDocTypeHandlersExt { [SubscribesTo(classstr(PrintMgmtDocType), delegatestr(PrintMgmtDocType, getDefaultReportFormatDelegate))] public static void getDefaultReportFormatDelegate(PrintMgmtDocumentType _docType, EventHandlerResult _result) { switch (_docType) { case PrintMgmtDocumentType::CustAccountStatement: _result.result(ssrsReportStr(CustAccountStatementExt, Report)); break; } } }
7. 为现有菜单项创建扩展
导航到 CustAccountStatementExt 输出菜单项并创建扩展。另请确保将 Object 属性的值设置为 CustAccountStatementExtControllerExt,以将用户导航重定向。
8. 更新Print management settings
转至应付账款 > 查询和报告 > 设置 > 表单 > 表单设置 单击打印管理,找到文档配置设置,然后选择自定义设计
关于如何根据不同的公司打印不同的报表Design,请参考:
如何通过Print management 打印SSRS报表(how-to-print-ssrs-report-using-print-management) » Microsoft Dynamics AX/365 FO Developer`s Blog
great