System Classes Ranges using MS axapta
SysQuery query;
SysQueryRun queryRun;
QueryBuildDataSource custInvoiceJourDS;
QueryBuildRange rangeInvoiceAccount, rangeInvoiceDate, rangeDimensionDepartment;
;
query = new Query();
custInvoiceJourDS = query.addDataSource(tablenum(CustInvoiceJour));
rangeInvoiceAccount = custInvoiceJourDS.addRange(fieldnum(CustInvoiceJour, InvoiceAccount));
rangeInvoiceAccount.value(queryValue("5000"));
rangeInvoiceDate = custInvoiceJourDS.addRange(fieldnum(CustInvoiceJour, InvoiceDate));
rangeInvoiceDate.value(queryRange(datenull(), systemdateget()));
rangeDimensionDepartment = custInvoiceJourDS.addRange(fieldId2Ext(
fieldnum(CustInvoiceJour, Dimension), 1));
rangeDimensionDepartment.value(queryValue("Sales"));
queryRun = new SysQueryRun(query);
queryRun.prompt();