SSRS Report using DP,Contract,Controller Classes with Parameter table in Ax 2012

SSRS

Here i combined two tables, from second table i am getting the Address

CODE:

DP Class

[ SRSReportQueryAttribute (querystr(Bill_TabMethod_SSRS)),
SRSReportParameterAttribute(classstr(Bill_TabMethodContract))
]
class Bill_TabMethodDP extends SrsReportDataProviderPreProcess
{
Bill_TabMethodTmp bill_TabMethodTmp;

}

[SRSReportDataSetAttribute(“Bill_TabMethodTmp”)]
public bill_TabMethodTmp getBill_TabMethodTmp()
{
select * from bill_TabMethodTmp;
return bill_TabMethodTmp;
}

[SysEntryPointAttribute(true)]
public void processReport()
{
BIll_Child billChild;
BillChildParm billchildparm;
Bill_TabMethod btm;

QueryRun queryRun;
Query query;
Bill_TabMethod billbuffer;
Bill_TabMethodContract srsBill_TabMethodContract;
CustName custName;
ItemName itemName;
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange queryBuildRange;

query = this.parmQuery();

srsBill_TabMethodContract = this.parmDataContract() as Bill_TabMethodContract;
custName = srsBill_TabMethodContract.parmCustName();
itemName = srsBill_TabMethodContract.parmitemName();

// Add parameters to the query.
queryBuildDataSource = query.dataSourceTable(tablenum(Bill_TabMethod));

/*
if(custName)
{
queryBuildRange = queryBuildDataSource.findRange(fieldnum(Bill_TabMethod, CustName));
if (!queryBuildRange)
{
queryBuildRange = queryBuildDataSource.addRange(fieldnum(Bill_TabMethod, CustName));
}
// If an account number has not been set, then use the parameter value to set it.
if(!queryBuildRange.value())
queryBuildRange.value(custName);
}
*/

queryBuildRange = queryBuildDataSource.addRange(fieldnum(Bill_TabMethod, CustName));
// queryBuildRange = queryBuildDataSource.addRange(fieldnum(Bill_TabMethod, ItemName));
queryBuildRange.value(custName);
//queryBuildRange.value(itemName);

queryRun = new QueryRun(query);

while(queryRun.next())
{
billbuffer = queryRun.get(tableNum(Bill_TabMethod));

bill_TabMethodTmp.CustName=billbuffer.CustName;
bill_TabMethodTmp.ItemName=billbuffer.ItemName;
bill_TabMethodTmp.Price=billbuffer.Price;
bill_TabMethodTmp.Quatity=billbuffer.Quatity;
bill_TabMethodTmp.Discount=billbuffer.Discount;
bill_TabMethodTmp.Vat=billbuffer.Vat;
bill_TabMethodTmp.TotalAmt=billbuffer.TotalAmt;
bill_TabMethodTmp.NetAmt=billbuffer.NetAmt;

select billchildparm;
if(billchildparm.Number==1)
{
select billChild where billChild.CustName==billbuffer.CustName;
bill_TabMethodTmp.Address=billChild.Address;
}
else
{
while select billChild where billChild.CustName==billbuffer.CustName
bill_TabMethodTmp.Address+=billChild.Address;
}

bill_TabMethodTmp.insert();

}
/*
//Directly inserting from the Base Table

srsBill_TabMethodContract = this.parmDataContract() as Bill_TabMethodContract;
custName = srsBill_TabMethodContract.parmCustName();
//itemName = srsBill_TabMethodContract.parmitemName();
select btm where btm.CustName==custName;

bill_TabMethodTmp.CustName=btm.CustName;
bill_TabMethodTmp.ItemName=btm.ItemName;
bill_TabMethodTmp.Price=btm.Price;
bill_TabMethodTmp.Quatity=btm.Quatity;
bill_TabMethodTmp.Discount=btm.Discount;
bill_TabMethodTmp.Vat=btm.Vat;
bill_TabMethodTmp.TotalAmt=btm.TotalAmt;
bill_TabMethodTmp.NetAmt=btm.NetAmt;
bill_TabMethodTmp.insert();
bill_TabMethodTmp.clear();

*/

Contract Class

class Bill_TabMethodContract
{
CustName custName;
ItemName itemName;
Description address;
}
}

[DataMemberAttribute(“CustName”)]
public CustName parmCustName(CustName _custName = custName)
{
custName = _custName;
return custName;
}

Controller Class

class Bill_TabMethodController extends SrsReportRunController
{
Bill_TabMethodContract contract;
Bill_TabMethod billTable;
}

protected void preRunModifyContract()
{
contract = this.parmReportContract().parmRdpContract() as Bill_TabMethodContract;
if(this.parmArgs().dataset() == tableNum(Bill_TabMethod))
{
billTable = this.parmArgs().record();
contract.parmCustName(billTable.CustName);
}

}

public static void main(Args args)
{
Bill_TabMethodController srs;
srs = new Bill_TabMethodController ();
srs.parmReportName(ssrsReportStr(JKTestReport,PrecisionDesign1));
srs.parmArgs(args);

srs.parmShowDialog(true);
srs.startOperation();
}

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s