AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX: За рубежом > DAX in English
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск Все разделы прочитаны

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 14.12.2007, 13:56   #1  
ist is offline
ist
Участник
 
60 / 10 (1) +
Регистрация: 29.07.2007
Query sort field autoSum
Hi,
How can I set AutoSum property on sorting field into Query with x++




I do this into Query Init method but without success.
X++:
    this.query().dataSourceTable(tablenum(LedgerTrans)).sortClear();
    this.query().dataSourceTable(tablenum(LedgerTrans)).addSortField(fieldnum(LedgerTrans, Voucher), SortOrder::Ascending);
    this.query().dataSourceTable(tablenum(LedgerTrans)).addSortField(fieldnum(LedgerTrans, TransDate), SortOrder::Ascending);
    this.query().dataSourceTable(tablenum(LedgerTrans)).addSortField(fieldnum(LedgerTrans, AccountNum), SortOrder::Ascending);
    this.query().dataSourceTable(tablenum(LedgerTrans)).autoSum(fieldNum(LedgerTrans, Voucher));
thank's in advance
Старый 14.12.2007, 14:51   #2  
kashperuk is offline
kashperuk
Участник
Аватар для kashperuk
MCBMSS
Соотечественники
Сотрудники Microsoft Dynamics
Лучший по профессии 2017
Лучший по профессии 2015
Лучший по профессии 2014
Лучший по профессии 2011
Лучший по профессии 2009
 
4,361 / 2084 (78) +++++++++
Регистрация: 30.05.2004
Адрес: Atlanta, GA, USA
If you are talking about sum(Field), than it's pretty easy:
X++:
this.query().dataSourceTable(tablenum(LedgerTrans)).addSelectionField(fieldNum(LedgerTrans, Voucher), SelectionField::Sum);
Старый 14.12.2007, 15:01   #3  
ist is offline
ist
Участник
 
60 / 10 (1) +
Регистрация: 29.07.2007
Цитата:
Сообщение от kashperuk Посмотреть сообщение
If you are talking about sum(Field), than it's pretty easy:
X++:
this.query().dataSourceTable(tablenum(LedgerTrans)).addSelectionField(fieldNum(LedgerTrans, Voucher), SelectionField::Sum);
No... I have to make auto sum for this fields from the report, for that sumAll property = Yes, when voucher field has changed.

See report LedgerTransListAccount/Query/DataSource/LedgerTrans/Sorting/AccountNum-> properties->AutoSum = Yes. Exact this I want to make with X++ , not in AOT.

Последний раз редактировалось ist; 14.12.2007 в 15:50.
Старый 14.12.2007, 17:34   #4  
Russland is offline
Russland
MCTS
Аватар для Russland
MCBMSS
 
267 / 116 (4) +++++
Регистрация: 17.10.2005
Адрес: Донеччина, Україна
ist

First of all, you don't properly use autoSum() method in your example.
Look at standard code e.g.: \Classes\ProjReport_CommittedCost\modifyQuery how autoSum() works.

Second... Do the way that kashperuk suggested you.
__________________

В глухомани, в лесу Несмотря на красу Дни проводит Лиса Патрикевна. Я никак не пойму Отчего, почему Не пускают куму На деревню
Старый 27.03.2008, 16:48   #5  
Volodymyr is offline
Volodymyr
Участник
 
36 / 21 (1) +++
Регистрация: 03.11.2006
Адрес: Киев
This job try to demonstrate how the SysReportRun class work. And how use AutoSum & AutoHeader parameters.
Settings:
1) Create table "People" with such fields: Surname(str), Salary(EDT-Amount), MyGroup(str)
2) Fill table

Notice:
- Grand total perform only on the fields derived from Amount (from latest build AmountMST also)
- The Print Options dosnt work proper

X++:
static void Job2(Args _args)
{
    SysReportRun            sysReportRun;
    Args                    args = new Args(reportstr(SysReportAuto));
    People                  people;
    SysQueryRun             sysQueryRun;
    Query                   query = new Query();
    QueryBuildDataSource    queryBuildDataSource;
    Report                  report;
    ReportDesign            reportDesign;
    ReportAutoDesignSpecs   reportAutoDesignSpecs;
    ReportSection           reportSection;
    Object                  reportControl;
    ReportRealControl       reportRealControl;
    ;
    //Init reportRun
    sysReportRun        = classfactory.reportRunClass(args);
    sysReportRun.init();
    //Setup group total field(s) with autoSum and autoHeader
    queryBuildDataSource = query.addDataSource( tablenum(people) );
    queryBuildDataSource.addSortField( fieldnum(people, Salary) );
    queryBuildDataSource.autoSum(1, true);//Autosum for 1st sort field
    queryBuildDataSource.addSortField( fieldnum(people, MyGroup) );
    queryBuildDataSource.autoHeader(2, true);//AutoHeader for 2nd sort field
    //Init queryRun on reportRun
    sysQueryRun = new SysQueryRun( query );
    sysQueryRun.promptLoadLastUsedQuery( false );// use created queryRun
    sysReportRun.queryRun( sysQueryRun );
    //Setup and create repor design
    report = sysReportRun.report();
    report.query(sysReportRun.queryRun().query());
    reportDesign = report.design();
 
    reportDesign.caption( 'Test for people' );
    reportDesign.reportTemplate( 'FrontPage' );
    reportAutoDesignSpecs = reportDesign.autoDesignSpecs();
        // Add section and fields on the report
        reportSection = reportAutoDesignSpecs.addSection(ReportBlockType::Body, people.TableId);
        reportControl = reportSection.addControl(people.TableId, fieldnum(people, Name));
        reportControl = reportSection.addControl(people.TableId, fieldnum(people, MyGroup));
        reportControl = reportSection.addControl(people.TableId, fieldnum(people, Salary));
        reportRealControl = reportControl; //calculate grand total on this field
        reportRealControl.sumAll( true );
    reportAutoDesignSpecs.grandTotal( true );
    //Block form usage
    sysReportRun.queryRun().query().interactive( false );
    report.interactive( false );
    //Setup print options:
    //Print ranges, print totals only, print grand total, remove...repetitive, remove ...identical
    sysReportRun.printRemoveRepeatedHeaders(true);
    sysReportRun.buildPrintRemoveRepeatedHeaders();
    sysReportRun.run();
}

Последний раз редактировалось Volodymyr; 27.03.2008 в 16:52.
За это сообщение автора поблагодарили: mbal (1).
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Dynamics AX: QueryRun and Query Objects - Binding operation failed to allocate buffer space Blog bot DAX Blogs 0 03.04.2009 08:05
palleagermark: Sample union query from AX 2009 Blog bot DAX Blogs 0 11.07.2008 20:05
Filter By Field ist DAX in English 7 30.10.2007 17:49
Dynamics AX Geek: Using query() Blog bot DAX Blogs 0 28.10.2006 16:40
Проблема с составлением Query axaLearner DAX: Программирование 10 01.12.2005 15:00
Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 04:55.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.