{"id":9,"date":"2023-06-30T06:38:44","date_gmt":"2023-06-30T06:38:44","guid":{"rendered":"http:\/\/d365dev.local\/?p=8"},"modified":"2024-07-19T17:49:37","modified_gmt":"2024-07-19T09:49:37","slug":"how-to-create-ssrs-report-in-d365fo-part1-report-data-provider-class","status":"publish","type":"post","link":"https:\/\/dev-d365fo.pantheonsite.io\/how-to-create-ssrs-report-in-d365fo-part1-report-data-provider-class\/","title":{"rendered":"\u5982\u4f55\u5728D365FO\u521b\u5efaSSRS\u62a5\u8868\uff08\u4e00\uff09Report Data Provider Class\uff08how-to-create-ssrs-report-in-d365fo-part1-report-data-provider-class\uff09"},"content":{"rendered":"\n

Report data provider class<\/h1>\n\n\n\n

\u7ee7\u627fSrsReportDataProviderPreProcessTempDB<\/h2>\n\n\n\n

\u58f0\u660e\u6240\u7528\u5230\u7684Contract \u548c Query\u8fd8\u6709\u5176\u4ed6\u53d8\u91cf<\/p>\n\n\n\n

\n[\n    SRSReportParameterAttribute(classStr(Demo_InventJournalTransTransferContract)),\n    SRSReportQueryAttribute(queryStr(Demo_InventJournalTransTransferQuery))\n]\nclass Demo_InventJournalTransTransferDP extends SrsReportDataProviderPreProcessTempDB\n{\n}\n<\/pre>\n\n\n\n

SRSReportDataSetAttribute<\/h2>\n\n\n\n

\u5b9a\u4e49\u4e34\u65f6\u8868\u4fdd\u5b58\u62a5\u8868\u7684Header\uff0cFooter \u7b49\u6570\u636e<\/p>\n\n\n\n

\n[\n    SRSReportDataSetAttribute('Demo_InventJournalTransTransferHeaderTMP')\n]\npublic Demo_InventJournalTransTransferHeaderTMP getHeader()\n{\n    select * from header;\n    return header;\n}\n\n[\n    SRSReportDataSetAttribute('Demo_InventJournalTransTransferFooterTMP')\n]\npublic Demo_InventJournalTransTransferFooterTMP getFooter()\n{\n    select * from footer;\n    return footer;\n}\n<\/pre>\n\n\n\n

Process report<\/h2>\n\n\n\n

\u5904\u7406\u62a5\u8868\u7684\u6570\u636e<\/p>\n\n\n\n

\npublic void processReport()\n{\n    Demo_InventJournalTransTransferContract contract            = this.parmDataContract();\n\n    super();\n    \n    inventDimParm       = this.initInventDimParm(contract);\n    inventDimSetup      = this.getInventDimFieldList();\n    \n    this.fetchDetail();\n    this.fetchHeader();\n    this.fetchFooter();\n    \n}\n<\/pre>\n\n\n\n

\u5982\u4f55\u6dfb\u52a0\u516c\u53f8LOGO<\/h3>\n\n\n\n
\nCompanyInfo companyInfo = CompanyInfo::find();\ntableBuffer.CompanyLogo = CompanyImage::findByRecord(companyInfo).Image;\n<\/pre>\n\n\n\n

Query\u4e2d\u4f7f\u7528\u4e34\u65f6\u8868<\/h2>\n\n\n\n

\u6ce8\u610f\uff1a\u5728\u62a5\u8868\u6293\u53d6\u6570\u636e\u7684\u65f6\u5019\u6211\u4eec\u7ecf\u5e38\u4f1a\u7528\u5230Query\u800c\u4e0d\u662fwhile select,\u5728Query\u4e2d\u4f7f\u7528\u4e34\u65f6\u8868,\u53ea\u9700\u8981\u52a0\u4e0asetCursor() (or setRecord())\uff0c\u4e0b\u9762\u662f\u4e00\u4e2a\u4f8b\u5b50\uff1a<\/p>\n\n\n\n

\nTmpTableName name;\n \nname.RefTableId = 1;\nname.TableName = 'TableA';\nname.insert();\n \nTmpTableIdMap map;\nmap.MainTableId = 1;\nmap.MainFieldId = 42;\nmap.insert();\n \nQuery query = new Query();\nQueryBuildDataSource nameDs = query.addDataSource(tableNum(TmpTableName));\n \nQueryBuildDataSource mapDs = nameDs.addDataSource(tableNum(TmpTableIdMap));\nmapDs.addLink(fieldNum(TmpTableName, RefTableId), fieldNum(TmpTableIdMap, MainTableId));\n \nQueryRun qr = new QueryRun(query);\nqr.setCursor(name);\nqr.setCursor(map);\n \nwhile (qr.next())\n{\n    TmpTableName nameFetched = qr.get(tableNum(TmpTableName));\n    TmpTableIdMap mapFetched = qr.get(tableNum(TmpTableIdMap));\n \n    info(strFmt('%1 - %2', nameFetched.TableName, mapFetched.MainFieldId));\n}\n<\/pre>\n\n\n\n

\u6709\u65f6\u5019\u62a5\u8868\u4f1a\u9700\u8981\u663e\u793a\u6761\u5f62\u7801\u6216\u8005\u4e8c\u7ef4\u7801\uff0c\u8bf7\u53c2\u8003\u4e00\u4e0b\u94fe\u63a5\uff1a<\/p>\n\n\n