SSRS report with multi selection lookups and multi parameters of contract
// Contract
[
DataContractAttribute,
SysOperationContractProcessingAttribute(classStr(KAPDilutionCalcWithParametersUIBuilder))
]
class KAPDilutionCalcWithParametersContract
{
List selectedCustAcc;
List selectedItem;
List selectedDiv;
[
DataMemberAttribute('selectedCustAcc'),
SysOperationLabelAttribute("Customers"),
SysOperationDisplayOrderAttribute('1'),
AifCollectionTypeAttribute('return', Types::String)
]
public List parmSelectedCustAcc(List _selectedCustAcc= selectedCustAcc)
{
selectedCustAcc = _selectedCustAcc;
return selectedCustAcc;
}
[
DataMemberAttribute('selectedItem'),
SysOperationLabelAttribute("Items"),
SysOperationDisplayOrderAttribute('2'),
AifCollectionTypeAttribute('return', Types::String)
]
public List parmSelectedItem(List _selectedItem= selectedItem)
{
selectedItem = _selectedItem;
return selectedItem;
}
[
DataMemberAttribute('selectedDiv'),
SysOperationLabelAttribute("Divisions"),
SysOperationDisplayOrderAttribute('3'),
AifCollectionTypeAttribute('return', Types::String)
]
public List parmSelectedDiv(List _selectedDiv= selectedDiv)
{
selectedDiv = _selectedDiv;
return selectedDiv;
}
}
// UI Bulider
class KAPDilutionCalcWithParametersUIBuilder extends SysOperationAutomaticUIBuilder
{
DialogField df_Items;
DialogField df_CustAccount;
DialogField df_Divisions;
SysLookupMultiSelectCtrl ctrlCustomers;
SysLookupMultiSelectCtrl ctrlItems;
SysLookupMultiSelectCtrl ctrlDivisions;
//Override this to add dialog field
protected DialogField addDialogField(IdentifierName _methodName, Object _dataContract = this.dataContractObject())
{
DialogField dialogField;
switch (_methodName)
{
case methodStr(KAPDilutionCalcWithParametersContract, parmSelectedItem):
df_Items = this.dialog().addField(extendedTypeStr(Description1000), "Items");
dialogField = df_Items;
break;
case methodStr(KAPDilutionCalcWithParametersContract, parmSelectedCustAcc):
df_CustAccount = this.dialog().addField(extendedTypeStr(Description1000), "Customers");
dialogField = df_CustAccount;
break;
case methodStr(KAPDilutionCalcWithParametersContract, parmSelectedDiv):
df_Divisions = this.dialog().addField(extendedTypeStr(Description1000), "Divisions");
dialogField = df_Divisions;
break;
default:
dialogField = super(_methodName, _dataContract);
break;
}
return dialogField;
}
public void getFromDialog()
{
KAPDilutionCalcWithParametersContract dataContract = this.dataContractObject() as KAPDilutionCalcWithParametersContract;
super();
dataContract.parmSelectedItem(con2List(ctrlItems.getSelectedFieldValues()));
dataContract.parmSelectedCustAcc(con2List(ctrlCustomers.getSelectedFieldValues()));
dataContract.parmSelectedDiv(con2List(ctrlDivisions.getSelectedFieldValues()));
}
public void postRun()
{
Query query;
container selectedFieldsCust = [tableNum(CustTable), fieldNum(CustTable, AccountNum)];
container selectedFieldsItem = [tableNum(InventTable), fieldNum(InventTable, ItemId)];
container selectedFieldsDiv = [tableNum(SAKDivision), fieldNum(SAKDivision, DivisionId)];
KAPDilutionCalcWithParametersContract dataContract = this.dataContractObject() as KAPDilutionCalcWithParametersContract;
super();
query = new Query(queryStr(CustTableSRS));
ctrlCustomers = SysLookupMultiSelectCtrl::constructWithQuery(this.dialog().dialogForm().formRun(),df_CustAccount.control(), query, false, selectedFieldsCust);
query = new Query(queryStr(KAPInventTableSRS));
ctrlItems = SysLookupMultiSelectCtrl::constructWithQuery(this.dialog().dialogForm().formRun(), df_Items.control(), query, false, selectedFieldsItem);
query = new Query();
Query.addDataSource(tableNum(SAKDivision));
ctrlDivisions = SysLookupMultiSelectCtrl::constructWithQuery(this.dialog().dialogForm().formRun(), df_Divisions.control(), query, false, selectedFieldsDiv);
}
}
Retrieve multiselection values from contract
str divListStr;
SAKDivisionId divId;
SAKInventTable sakInvent;
KAPDilutionCalcWithParametersTable parmTableDiv;
divList = new ListIterator(selectedDiv);
while (divList.more())
{
divId = divList.value();
if(divId)
{
insert_recordset parmTableDiv(AccountNum,ItemId)
select CustAccount,ItemId from IntrestAllocationTable
group by IntrestAllocationTable.CustAccount,IntrestAllocationTable.ItemId
exists join sakInvent
where sakInvent.DivisionId == divId
&& sakInvent.ItemId == IntrestAllocationTable.ItemId;
}
divList.next();
}
Comments
Post a Comment