Monday, 16 December 2013

Report to display current record in the Form On button click in ax 2009


·         In click method (First Method)
void clicked()
{
    Args                    args;
    ReportRun               reportRun;
;
    super();

    args = new Args();
    args.name(reportStr(NSGEmplVacations));

    reportRun = new ReportRun(args);
    reportrun.report().interactive(false);
    reportrun.query().interactive(false);
                                                                SysQuery::findOrCreateRange(reportrun.query().dataSourceTable(tablenum(EmplTable)),
                  fieldnum(EmplTable, EmplId)).value(Vacations.EmplId);
    reportRun.init();
    reportRun.run();
}
·         In the click method(Second Method)
1.       void clicked()
{
    Args        args;
    ReportRun   reportRun;
    NASVacationTransId      _VacationTransId;
      ;
    args = new args();
    args.name(reportstr(NSG_VacationRequestReport));
    args.record(Vacations);
    args.parm(Vacations.NASVacationTransId);
    reportRun = classFactory.reportRunClass(args);
    reportRun.init();
    reportRun.run();
}

2.       public boolean fetch()
{
    boolean ret;

this.query().dataSourceTable(TableNum(Vacations)).addRange(FieldNum(Vacations,    NASVacationTransId)).value(_VacationTransID);
    ret = super();

    return ret;
}

3.       public void init()
{
    _VacationTransID    = element.args().parm();
    _vacTable           = element.args().record();
    super();

}
Hi, 
Normally developers need the term and condition or other stuff to be displayed only on the last page .To insert the footer only on the last page of Axapta report do the following stes.
1. Declare a boolean variable (pageFooter) in report class declaration method .

             public class ReportRun extends ObjectRun
            {
                 boolean pageFooter;
            }
2. Override the report fetch method with query 
          public boolean fetch()
          {
               boolean ret;
               ret = super();
               printPageFooter=false;
                while(queryrun.next())
                {


                }
               printPageFooter=true;
               return true;
          }


3. Override the executeSection method of footer 
      
          public void executeSection()
          {
                if(printPageFooter==true)


                super();
           }


Reportàmethodsà initFromCaller
public void initFromCaller(Args _args)
{
    BiddingMainCostSheetTable     _BiddingMainCostSheetTable;
    BidServiceCostSheetTable _bidServiceCostSheetTable;
  //  BidSvcsBOQSectionTable _bidSvcsBOQSectionTable;
    QueryBuildDataSource    qbds;
    ;
    if (_args.caller())
    {
        if (! _args.record().RecId)
            throw error(strfmt("@SYS22338",funcname()));

        switch (_args.dataset())
        {
            case tablenum(BiddingMainCostSheetTable):
                _BiddingMainCostSheetTable  = _args.record();
                qbds = element.query().dataSourceTable(tablenum(BiddingMainCostSheetTable));
                qbds.clearRanges();
                SysQuery::findOrCreateRange(qbds, fieldnum(BiddingMainCostSheetTable, MainCostSheetId));

                if (_BiddingMainCostSheetTable.MainCostSheetId)
                {
                    SysQuery::findOrCreateRange(qbds, fieldnum(BiddingMainCostSheetTable, MainCostSheetId)).value(_BiddingMainCostSheetTable.MainCostSheetId);
                }
                break;
            case tablenum(BidServiceCostSheetTable):
                _bidServiceCostSheetTable = _args.record();
                qbds = element.query().dataSourceTable(tablenum(BiddingMainCostSheetTable));
                qbds.clearRanges();
                SysQuery::findOrCreateRange(qbds, fieldnum(BiddingMainCostSheetTable, MainCostSheetId));

                if (_bidServiceCostSheetTable.MainCostSheetId)
                {
                    SysQuery::findOrCreateRange(qbds, fieldnum(BiddingMainCostSheetTable, MainCostSheetId)).value(_bidServiceCostSheetTable.MainCostSheetId);
                }
                break;           
            default:
                throw error(strfmt("@SYS23396",funcname()));
        }
    }
}


No comments:

Post a Comment