Get multiple records from caller data source in report.
Contract class:
[DataContractAttribute] public class TestrContract { List refRecId; [ DataMemberAttribute("refRecID"), AifCollectionTypeAttribute("_refRecID", Types::Int64) ] public List parmrefRecID(List _refRecID = refRecID) { refRecID = _refRecID; return refRecID; } }
------------------------------------------------------------------------ Controller class: class TestController extends SrsReportRunController { public static TestController construct() { return new TestController(); } public static void main(Args _args) { TestController controller = TestController::construct(); controller.parmReportName(ssrsReportStr(TestReport, Report)); controller.parmArgs(_args); controller.parmShowDialog(false); controller.startOperation(); } protected void prePromptModifyContract() { TestCustomer testCustomer, testCustomerLoc; FormDataSource testCustomer_DS; TestrContract contract; List myList; contract = this.parmReportContract().parmRdpContract(); if(this.parmargs().dataset() == tableNum(TestCustomer)) { testCustomer = this.parmargs().record(); testCustomer_DS = FormDataUtil::getFormDataSource(testCustomer); //whsLoadTable.dataSource(); myList = new List(Types::Int64); for (testCustomerLoc = getFirstSelection(testCustomer_DS); testCustomerLoc; testCustomerLoc = testCustomer_DS.getNext()) { myList.addStart(testCustomerLoc.RecId); } contract.parmrefRecID(myList); } } }
------------------------------------------------------------------------ Dp class: [ SrsReportQueryAttribute(queryStr(TestQuery)), SrsReportParameterAttribute(classStr(TestContract)) ] class TestDP extends SRSReportDataProviderBase { TestTmp testTmp; [ SrsReportDataSetAttribute(tableStr(TestTmp)) ] public TestTmp getTestTmp() { select testTmp; return testTmp; } public void processReport() { Query query; QueryBuildDataSource qbds; QueryRun qr; TestContract contract; TestCustomer testCustomer; container pack, testcon; List myList; ListIterator listterator; query = this.parmQuery(); qbds = query.dataSourceTable(tableNum(TestCustomer)); contract = this.parmDataContract() as TestContract; myList = contract.parmrefRecID(); listterator = new ListIterator(myList); pack = myList.pack();//convert to container for (int i = 1 ; i <= conLen(pack) ; i++) { if (TestCustomer::findByRecId(conPeek(pack, i)).RecId) { testcon += conPeek(pack, i); } } if (testcon != conNull()) { qbds.addrange(fieldnum(TestCustomer, RecId)).value(con2Str(testcon)); } qr = new QueryRun(query); while(qr.next()) { testCustomer = qr.get(tableNum(TestCustomer)); this.insertIntoTmp(testCustomer); } }
------------------------------------------------------------------------
Keep Daxing!!
No comments:
Post a Comment