Tuesday, July 17, 2018

Add Business Logic for the Report

1. Right-click SrsRdpSampleClass, point to Override method, and then click processReport.

2. Edit the method so that it contains the following code.



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
public void processReport()
{ AccountNum accountNumber;
CustAccountStatement custAcctStmt;
boolean boolInclTax;
Query query;
QueryRun queryRun;
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange queryBuildRange;
CustTable queryCustTable;
SrsRdpContractSample dataContract; // Get the query from the runtime using a
dynamic query.
// This base class method reads the query specified in the SSRS
ReportQueryAttribute attribute.
query = this.parmQuery(); // Get the parameters passed from runtime.
// The base class methods read the SRSReportParameterAttribute attribute.
dataContract = this.parmDataContract();
accountNumber = dataContract.parmAccountNum();
custAcctStmt = dataContract.parmAccountStmt();
boolInclTax = dataContract.parmInclTax(); // Add parameters to the query.
queryBuildDataSource =
query.dataSourceTable(tablenum(CustTable)); if(accountNumber)
{
queryBuildRange =
queryBuildDataSource.findRange(fieldnum(CustTable, AccountNum)); if
(!queryBuildRange)
{
queryBuildRange =
queryBuildDataSource.addRange(fieldnum(CustTable, AccountNum));
} // If an account number has not been set, then use the parameter value to set it.
if(!queryBuildRange.value())
queryBuildRange.value(accountNumber); } if(custAcctStmt)
{ queryBuildRange = queryBuildDataSource.findRange(fieldnum(CustTable,
AccountStatement));
if (!queryBuildRange)
{
queryBuildRange = queryBuildDataSource.addRange(fieldnum(CustTable,
AccountStatement));
} // If an account statement has not been set, then use the parameter value to set
it.
if(!queryBuildRange.value())
queryBuildRange.value(int2str(custAcctStmt)); } if(boolInclTax)
{ queryBuildRange =
queryBuildDataSource.findRange(fieldnum(CustTable, InclTax)); if
(!queryBuildRange)
{
queryBuildRange = queryBuildDataSource.addRange(fieldnum(CustTable,
InclTax));
} // If flag to include tax has not been set, then use the parameter value to set it.
if(!queryBuildRange.value())
queryBuildRange.value(int2str(boolInclTax)); } // Run the query with modified
ranges.
queryRun = new QueryRun(query); ttsbegin;
while(queryRun.next())
{ tmpCust.clear();
queryCustTable = queryRun.get(tablenum(CustTable));
tmpCust.AccountNum = queryCustTable.AccountNum;
tmpCust.CustName = queryCustTable.name();
tmpCust.LogisticsAddressing = queryCustTable.address();
tmpCust.CustGroupId = queryCustTable.CustGroup;
tmpCust.Phone = queryCustTable.phone();
tmpCust.CustInvoiceAccount = queryCustTable.InvoiceAccount;
tmpCust.CustAccountStatement = queryCustTable.AccountStatement;
tmpCust.InclTax = queryCustTable.InclTax;
tmpCust.insert(); }
ttscommit; }

3. Save the method and close the editor.

Best Regards,
Hossein Karimi

No comments:

Post a Comment

Configure the Firewall on the Enterprise Portal Server

After you install Enterprise Portal, enable Web Server (HTTP) in Windows Firewall. If you do not enable the web server in Windows Firewall...