Suppose I have a requirement where I have to show data related to one sales id.

Step 1) Create a query SampleSalesTableQuery with SalesTable as datasource and create a temp table with name SampleSalesTmpTable;

Step 2) Create contract class.


 

[DataContractAttribute]
public class SampleSalesContract
{
RecId recordId;

}

[DataMemberAttribute(‘RecordId’)]
public RecId parmRecordId(RecId _recordId = recordId)
{
recordId = _recordId;
return recordId;
}

 

Step 3) Create controller class


 

public class SampleSalesController extends SrsReportRunController
{
#define.reportName(‘ReportName.DesignName’)

SampleSalesContract contract;

SalesTable                 sTable;

}

protected void preRunModifyContract()
{

contract = this.parmReportContract().parmRdpContract() as SampleSalesContract;

sTable = this.parmArgs().record();
contract.parmRecordId(sTable.RecId);

super();

}

public static void main(Args _args)
{
SampleSalesController  formLetterController = new SampleSalesController();

formLetterController.parmArgs(_args);
formLetterController.parmReportName(#ReportName);
formLetterController.parmShowDialog(false);
formLetterController.startOperation();
}

 

Step 4) Create DP class.


 

[
SRSReportParameterAttribute(classStr(SampleSalesContract))
]
public class NTT_FakturPajakDP extends SRSReportDataProviderBase
{

RecId                                                  salesRecId;

SampleSalesTmpTable                       salesTmpTable;

}

 

[SRSReportDataSetAttribute(tableStr(SampleSalesTmpTable))]
public SampleSalesTmpTable getSampleSalesTmpTable()
{
select salesTmpTable;
return salesTmpTable;
}

private void insertSalesTableTmp()
{

//write code to insert data into temp table.

}

[SysEntryPointAttribute(false)]
public void processReport()
{

SampleSalesContract      contract;

Query      q;

QueryRun   qr;

q = new Query(queryStr(SampleSalesTableQuery));

contract = this.parmDataContract() as SampleSalesContract;

salesRecId = contract.parmRecordId();

q.dataSourceTable(tablenum(SalesTable)).addRange(fieldnum(SalesTable, RecId)).value(queryValue(salesRecId));

qr = new QueryRun(q);

while(qr.next())

{

this.insertSalesTableTmp();

}

}

Advertisements