Announcements
Greeting everyone
i have this report with 4 parameter
two of them for from date and to date
and other with Multi-Select Lookup parameter
but the problem is when i apply that not filtered
here my codes
public void processReport() { CompanyInfo companyInfo; CustTable custTable; Query query; QueryRun queryRun; ListIterator companyListIterator,custListIterator; QueryBuildDataSource qbdsCompany,qbdsCust; date fromDate,toDate; List companylist,custlist; SalesPurchByCompanyContract salesPurchByCompanyContract; contract = this.parmDataContract() as salesPurchByCompanyContract; fromDate=contract.parmfromDate(); toDate=contract.parmtoDate(); companyListIterator = new ListIterator(contract.parmSalesPurchByCompany()); custListIterator = new ListIterator(contract.parmSalesPurchByCompany()); while(companyListIterator.more()) { while(custListIterator.more()) { this.populateTmpTable(companyListIterator.value(),custListIterator.value(),fromDate,toDate); custListIterator.next(); } companyListIterator.next(); } }
this code for populate to temp table
public void populateTmpTable(String50 _dataarea,String255 _AccountNum,date _from,date _to) { CustTable custTable; CustInvoiceJour custInvoiceJour; DirPartyLocation dirPartyLocation; TaxRegistration taxRegistration; container conCompanies = [ 'scr','shw','sh', 'mgex','mbsg','scw' ,'spr','spw','wsof','wsom','wsos','wsow']; while select crossCompany : conCompanies custInvoiceJour where custInvoiceJour.dataAreaId ==_dataarea && (custInvoiceJour.InvoiceDate >= _from) && (custInvoiceJour.InvoiceDate <= _to) && custInvoiceJour.OrderAccount !=_AccountNum { salesPurchByCompTemp.clear(); salesPurchByCompTemp.CompanyID=custInvoiceJour.dataAreaId; salesPurchByCompTemp.InvoiceDate=custInvoiceJour.InvoiceDate; salesPurchByCompTemp.SalesBalance=custInvoiceJour.SalesBalance; salesPurchByCompTemp.SumTax=custInvoiceJour.SumTax; salesPurchByCompTemp.InvoiceAmount=custInvoiceJour.InvoiceAmount; salesPurchByCompTemp.InvoiceId=custInvoiceJour.InvoiceId; salesPurchByCompTemp.SalesId=custInvoiceJour.SalesId; salesPurchByCompTemp.IDCust=custInvoiceJour.OrderAccount; salesPurchByCompTemp.NameCust=custInvoiceJour.InvoicingName; select * from custTable where custTable.AccountNum==custInvoiceJour.OrderAccount; select * from taxRegistration where taxRegistration.DirPartyLocation==custTable.Party; salesPurchByCompTemp.TaxCustome=taxRegistration.RegistrationNumber; salesPurchByCompTemp.insert(); } }
Don't use company but custInvoiceJour and add other ranges same query
thanks for reply
i did as you said mr. ergun
by query and it's work fine with crosscompany
as you see here
public void processReport()
{
CompanyInfo companyInfo;
Query query;
QueryRun queryRun;
ListIterator companyListIterator,custListIterator;
QueryBuildDataSource qbdsCompany,qbdsCust;
date fromDate,toDate;
SalesPurchByCompanyContract salesPurchByCompanyContract;
contract = this.parmDataContract() as salesPurchByCompanyContract;
fromDate=contract.parmfromDate();
toDate=contract.parmtoDate();
companyListIterator = new ListIterator(contract.parmSalesPurchByCompany());
custListIterator = new ListIterator(contract.parmCustAccountList());
query = new Query(queryStr(SalesPurchByCompany));
qbdsCompany = query.dataSourceTable(tableNum(CompanyInfo));
while(companyListIterator.more())
{
qbdsCompany.addRange(
fieldNum(CompanyInfo, DataArea)).value(companyListIterator.value());
companyListIterator.next();
}
queryRun = new QueryRun(query);
while(queryRun.next())
{
companyInfo = queryRun.get(tableNum(companyInfo));
this.populateTmpTable(companyInfo.DataArea,fromDate,toDate);
}
}
but i have problem how about other parameter (customer)
how can i include it with company parameter?!
because left that one which i need to filtered too
Your case is not that the filter is not working but the way you use it is wrong.
Imagine you have 3 companies, 4 customers. You run the populateTmpTable 12 times.
So what does populateTmpTable do? It loops the table with a company-based filter. So you loop through the same company records 4 times(except some filtered records). The records in the tmp table are naturally multiplexed.
What you need to do is to run the entire structure with a crosscompany query (I shared the example link below).
Or while looping companies, add customers to the "while select" as a condition (this part can be the query alone to)
oh sorry your right
but only filter working only if there's one value on Multi-Select Lookup parameter
but if i selected multi value on Multi-Select Lookup parameter
it's not filtered
Take line 18 down two lines
The error is caused by the fact that you're trying to declare variables in the middle of a method, which isn't allowed in AX 2012.
If you want other statements than declarations before creating enumerator, declare variables, call other things and only then assign a value to the enumerator variable.
thanks all for reply
i did as you said mr.Martin but it got error
as you see here below
public void processReport() { CompanyInfo companyInfo; CustTable custTable; Query query; QueryRun queryRun; ListIterator companyListIterator,custListIterator; QueryBuildDataSource qbdsCompany,qbdsCust; date fromDate,toDate; //List companylist,custlist; SalesPurchByCompanyContract salesPurchByCompanyContract; contract = this.parmDataContract() as salesPurchByCompanyContract; ListEnumerator companyEnumerator = contract.parmSalesPurchByCompany().getEnumerator(); ListEnumerator custEnumerator = contract.parmCustAccountList().getEnumerator(); fromDate=contract.parmfromDate(); toDate=contract.parmtoDate(); while(companyEnumerator.moveNext()) { while(custEnumerator.moveNext()) { this.populateTmpTable(companyEnumerator.current(),custEnumerator.current(),fromDate,toDate); } } }
and how can i do it with Query as you said mr.Ergün
and here i have two Multi-Select Lookup parameter
You skipped a few steps in your debugging. As you see, if you just check the final resdult, you have no idea where the problem lies. You'll need more granular debugging.
For example, put a breakpoint to populateTmpTable() and check if you're getting expected values in parameters. If not, you'll know that you must look for the problem somewhere before populateTmpTable() call. If you do, you'll know that the problem is inside populateTmpTable() and you'll continue debugging there.
Personally, I would start by checking values of those lists direct in the contract object.
By the way, you should use ListEnumerator rather then ListIterator. For example:
ListEnumerator companyEnumerator = contract.parmSalesPurchByCompany().getEnumerator(); while (companyEnumerator.moveNext()) { info(companyEnumerator.current()); }
First of all, if you use Query, you can do what you want to do much easier.
Second, you are multiplexing Records. Company records are looping over and over (as many as custList's)
What kind of result did you come across? (If you say that the codes I added do not affect it, we will face a different problem.)
André Arnaud de Cal...
294,095
Super User 2025 Season 1
Martin Dráb
232,866
Most Valuable Professional
nmaenpaa
101,158
Moderator