mercredi 26 janvier 2011

How to fill a temporary table using a form and display its data in a report called from this form using X++

Create a form with two buttons one for inserting Data ' Insert' and the second for calling the report 'Print' .
Create the method "populate" in your form and fill the temporary table with the fileds you want to display in the report.
Override the clicked method for the button ' Insert' and use this code for example to fill the temporary table:

void clicked()
{
    super();
          TmpTestTable.setTmpData(element.populate());
          TmpTestTable_ds.research();
}

To print the report using this data, we need an intermediate class that extends RunBaseReport we create these following methods : first of all a constructor


void new(TmpTestTable _TmpTestTable,EmplId _emplId, PayrollJobStartDate _startDate,PayrollJobEndDate _endDate,PayrollIncrement _payrollIncrement)
{
    ;
    TmpTestTable            = _TmpTestTable;
    EmplId                  = _emplId;
    PayrollJobStartDate     = _startDate;
    PayrollJobEndDate       = _endDate;
    PayrollIncrement        = _payrollIncrement;
    super();
 a method that returns the populated temporary table
 
TmpTestTable populate(EmplId _EmplId,PayrollJobStartDate _StartDate, PayrollJobEndDate _EndDate,PayrollIncrement  _payrollIncrement)
{
    return TmpTestTable;
}

 a method that calls the report

identifiername lastValueElementName()
{
    return ReportStr(TestReport);

The prompt method to prompt the query of the report with data

public boolean prompt()
{
    boolean ret;
    ;
    ret = super();

    this.queryRun().setRecord(this.populate(EmplId, payrollJobStartDate, payrollJobEndDate, payrollIncrement));

    return ret;

Finally in the print button used to call the report use this code: 

void clicked()
{
    TestClass               TestClass ;
    ;

    super();

    TestClass = new TestClass(TmpTestTable,TmpTestTable_EmplId.valueStr(), TmpTestTable_StartDate.dateValue(),TmpTestTable_EndDate.dateValue(),TmpTestTable_PayrollIncrement.value());

    if(TestClass.prompt())
    {
        TestClass.run();
    }

Resources:
http://blogs.msdn.com/cfs-filesystemfile.ashx/__key/CommunityServer-Components-PostAttachments/00-01-72-59-34/Application-Fundamentals.ppt

Happy Daxing! 

Aucun commentaire:

Enregistrer un commentaire