Показать сообщение отдельно
Старый 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).