Controller Class with data Contract Class

Gentleman, I need to do a report based on contract class with parameters, i dont know what I did wrong, but controller class dont call contract class to get parametrs, below my classes, any suggests are welcome :

class SSRSDemoController extends SrsReportRunController
{

}

protected void prePromptModifyContract()
{

SRDemoContract contract;

FormDataSource fds;
//get the reference of the current contract object

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

}

public client static void main(Args args)
{
//define the new object for controller class

SSRSDemoController ssrsDemoController = new SSRSDemoController();
//set the report name and report design to run
ssrsDemoController.parmReportName(ssrsReportStr(Oxf_relatorio_vendas_retail,PrecisionDesign1));

//pass the caller args to the controller
ssrsDemoController.parmArgs(args);
//execute the report

ssrsDemoController.startOperation();

}

//Contract Class

class SRDemoContract implements SysOperationValidatable

{

AccountNum vendAccountNum;

TransDate formDate,toDate;

RetailStoreId StoreId;

}

[DataMemberAttribute(‘FromDate’)]

public FromDate parmfromDate(TransDate _formDate = formDate)

{

formDate= _formDate;

return formDate;
}

[DataMemberAttribute(‘StoreId’)]
public RetailStoreId parmStoreId(RetailStoreId _storeid = StoreId)

{

StoreId= _storeid;
return StoreId;

}

[DataMemberAttribute(‘ToDate’)]
public ToDate parmtoDate(TransDate _toDate = toDate)

{

toDate= _toDate;
return toDate;

}

public boolean validate()
{
boolean isValid = true;

if (!formDate)

{
isValid = checkFailed(“Informe a Data Inicial”);

}
if (!toDate)

{
isValid = checkFailed(“Informe a Data Final”);

}
if (isValid && (formDate > toDate))

{
isValid = checkFailed(strfmt(“Data Inicial deve ser menor ou igual a data final!”, date2StrUsr(formDate, DateFlags::FormatAll), date2StrUsr(toDate, DateFlags::FormatAll)));

}
if (!StoreId)

{
isValid = checkFailed(“Informe a loja”);

}
return isValid;

}

Your contract class isn’t decorated with DataContractAttribute.

Hello Martin, thanks for observation, but still not works, i update the code and nothing happens.

I think you have not passed parameters to Report through controller class…

you have to pass parameters in controller class and then call report…

protected void prePromptModifyContract()

{

contract.parmStoreId(‘store id’);

}

let me know if it is not the case

Hi Krishna an Martin, i was doing a test and change this code line in controller class main method

ssrsDemoController.parmReportName(ssrsReportStr(LedgerCheckVoucher, Report));

Note that LedgerCheckVoucher report is a default AX report and run pretty good, my doubt now is: the param “Report” refered to design report name created at Visual Studio because I always used default report design name (AutoDesign1 or PrecisionDesign1) or what does param “Report” Mean? thanks for while.

Yes, it’s the report design name.

what do you mean param “Report” in your reply…

Regarding your data contract, you haven’t mentioned where you’re using it. Do you have a data provider taking your data contract as parameter, or what?

Yes Martin, I need the data contract to get de parametrs to DP class, but I´m not understanding why the contrller class do not invoque data contract class, do you hava a simple code examplo usind data contract, controlle and DP class to compare my code here? Below my DP class.

[SRSReportParameterAttribute(classStr(SRDemoContract))]

class SRDemoDP extends SRSReportDataProviderBase
{
SRDemoContract contract;
Oxf_Resumo_vendas_varejo Oxf_Resumo_vendas_varejo;
RetailFiscalReceipt_BR RetailFiscalReceipt_BR;
RetailFiscalReceiptLine_BR RetailFiscalReceiptLine_BR;
}

[SRSReportDataSetAttribute(tableStr(Oxf_Resumo_vendas_varejo))]
public Oxf_Resumo_vendas_varejo getOxf_Resumo_vendas_varejo()
{
select * from Oxf_Resumo_vendas_varejo
order by itemid asc;
return Oxf_Resumo_vendas_varejo;
}

[SysEntryPointAttribute]
public void processReport()
{
int cont=0;
date fromDate,toDate;
RetailStoreId storeid;
SRDemoContract SRDemoContract;
;

SRDemoContract = new SRDemoContract();

contract = this.parmDataContract() as SRDemoContract;

fromDate=contract.parmfromDate();

toDate=contract.parmtoDate();

storeid=contract.parmStoreId();

delete_from Oxf_Resumo_vendas_varejo;

ttsBegin;
while select status from RetailFiscalReceipt_BR
group by Status
join ItemId, sum (Quantity), sum (LineAmount), sum (linediscountamount), sum(CancelledQuantity) from RetailFiscalReceiptLine_BR
group by itemid
where RetailFiscalReceipt_BR.AccountingDate >= FromDate
&& RetailFiscalReceipt_BR.AccountingDate <= toDate
&& RetailFiscalReceiptLine_BR.StoreId == storeid
&& RetailFiscalReceiptLine_BR.TerminalId == RetailFiscalReceipt_BR.TerminalId
&& RetailFiscalReceiptLine_BR.TransactionID == RetailFiscalReceipt_BR.TransactionID
&& RetailFiscalReceiptLine_BR.CancelledQuantity == 0
&& RetailFiscalReceipt_BR.dataAreaId == curext()
&& ((RetailFiscalReceipt_BR.Status == FiscalDocumentStatus_BR::Approved
|| FiscalDocumentStatus_BR::Blank))

{

Oxf_Resumo_vendas_varejo.name = EcoResProductTranslation::findByProductLanguage(EcoResProduct::find(InventTable::find(RetailFiscalReceiptLine_BR.ItemId).Product).RecId,SystemParameters::getSystemLanguageId()).Name;
Oxf_Resumo_vendas_varejo.AccountingDate = RetailFiscalReceipt_BR.AccountingDate;
Oxf_Resumo_vendas_varejo.ItemId = RetailFiscalReceiptLine_BR.ItemId;
Oxf_Resumo_vendas_varejo.LineAmount = RetailFiscalReceiptLine_BR.LineAmount;
Oxf_Resumo_vendas_varejo.LineDiscountAmount = RetailFiscalReceiptLine_BR.LineDiscountAmount;
Oxf_Resumo_vendas_varejo.Unit = InventTableModule::find(RetailFiscalReceiptLine_BR.ItemId,ModuleInventPurchSales::sales,false).unitid;
Oxf_Resumo_vendas_varejo.CancelledQuantity = RetailFiscalReceiptLine_BR.CancelledQuantity;
Oxf_Resumo_vendas_varejo.Quantity = RetailFiscalReceiptLine_BR.Quantity;
if (InventTableModule::Find(RetailFiscalReceiptLine_BR.ItemId,ModuleInventPurchSales::Sales).NrOfItems>0)
Oxf_Resumo_vendas_varejo.AmountQuantity = InventTableModule::Find(RetailFiscalReceiptLine_BR.ItemId,ModuleInventPurchSales::Sales).NrOfItems * RetailFiscalReceiptLine_BR.Quantity;
else
Oxf_Resumo_vendas_varejo.AmountQuantity = RetailFiscalReceiptLine_BR.Quantity;
Oxf_Resumo_vendas_varejo.insert();
Cont++;
}
ttsCommit;

if (cont == 0)

{
info(‘Não existem dados para as datas informadas!’);
return;

}

}

Hi Erivelto

I hope u are facing the issue that instead of all parameter u are seeing may be couple of parameter . If so then solution is … you have to do a grouping of your parameter .

So kindly follow the step:

[

DataContractAttribute,

SysOperationGroupAttribute(‘Date’, “Date”, ‘1’),

SysOperationGroupAttribute(‘Others’, “Others”, ‘2’)

]

class SRDemoContract implements SysOperationValidatable

{

AccountNum vendAccountNum;

TransDate formDate,toDate;

RetailStoreId StoreId;

}

[

DataMemberAttribute(‘FromDate’),

SysOperationLabelAttribute(literalstr(“FromDate”)),

SysOperationHelpTextAttribute(literalstr(“FromDate”)),

SysOperationGroupMemberAttribute(‘Date’),

SysOperationDisplayOrderAttribute(‘1’)

]

public FromDate parmfromDate(TransDate _formDate = formDate)

{

formDate= _formDate;

return formDate;
}

[

DataMemberAttribute(‘ToDate’),

SysOperationLabelAttribute(literalstr(“ToDate”)),

SysOperationHelpTextAttribute(literalstr(“ToDate”)),

SysOperationGroupMemberAttribute(‘Date’),

SysOperationDisplayOrderAttribute(‘1’)

]

public ToDate parmfromDate(TransDate _toDate = toDate )

{

toDate = _toDate ;

return toDate ;
}

[

DataMemberAttribute(‘RetailStoreId’),

SysOperationLabelAttribute(literalstr(“RetailStoreId”)),

SysOperationHelpTextAttribute(literalstr(“RetailStoreId”)),

SysOperationGroupMemberAttribute(‘Others’),

SysOperationDisplayOrderAttribute(‘2’)

]

public RetailStoreId parmStoreId(RetailStoreId _storeid = StoreId)

{

StoreId= _storeid;
return StoreId;

}

Try this hope it will help u .

Thanks

sumit

I think it’s now time for you to explain what exactly doesn’t work.

Thanks all, sorry martin that i could not explain exactly what i wanted now I almost finishing my doubt´s :slight_smile: , I guess that de corect quetion now is, how can i do to send to DP class these (FromDate, Loja and ToDate) params before run the report? With contract class I can not get them, they come from RDP class.

this is the params form :

I dont now what the hells I can not printscreen the form with the params, but is normal sysdialog form with 3 params and printer and batch options, AX default.

Do you mean that your RDP class works but you’re not getting values that you set in the dialog? I thought that your problem was more deep before, especially because you didn’t have any valid data contract class on the beginning.

Yes Martin, it is! I can not understand (is the first time i need to do) how get the values from dialog, I guess data contract will sove this but I cant link data contract class with dialog input values, do you have any simple example for this?

You don’t need to do anything - SysOperation framework takes your data contract and build the dialog for you. Which part doesn’t work for you and how do you test it?

I Martin, I can´t get the values to DP class from SysOperation, when I run the code with debugger on i can´t see the params from dialog, if i put them manually inside the code it works as well.

example :

if i try the code:

contract.parmfromDate(today()); - it works!

but

contract.parmfromDate(); (waiting from dialog) it not works!

Sorry, I can’t say what happens in your system. Review that you don’t have any code that would break the standard functionality, compile your code and generate CIL, refresh the data source in Visual Studio, restart AOS to drop global cache and test your report again using Visual Studio (not using the deployed version). If it doesn’t help, it’s time to use the debugger.