2011-07-27

[AX2009] Method Dalam Report yg Sering Digunakan

Berikut method-method yg sering digunakan pada report.
public class ReportRun extends ObjectRun
{
     TransDate           fromDate;
     TransDate           toDate;
     real                subtotalQty, totalQty, subtotal, total,Qty;

     DialogField         dialogFrom;
     DialogField         dialogTo;

     #DEFINE.CurrentVersion(1)
     #LOCALMACRO.CurrentList
          fromDate,
          toDate
     #ENDMACRO
}

public Object dialog(Object _dialog)
{
     DialogRunBase dialog = _dialog;
     ;

     dialog.addGroup("@SYS40");
     dialogFrom = dialog.addFieldValue(typeid(FromDate),fromDate,"@SYS5209","@SYS5209");
     dialogTo = dialog.addFieldValue(typeid(ToDate), toDate,"@SYS14656","@SYS14656");
     return dialog;
}

public boolean getFromDialog()
{
     ;
     fromDate = dialogFrom.value();
     toDate = dialogTo.value();

     return true;
}
public container pack()
{
     return [#CurrentVersion, #CurrentList];
}
public boolean unpack(container packedClass)
{
     boolean _ret;
     Integer version = conpeek(packedClass,1);
     ;

     switch(version)
     {
          case #CurrentVersion:
               [version, #CurrentList] = packedClass;
               _ret = true;
               break;
          default:
               _ret = false;
               break;
     }
     return _ret;
}
boolean validate(Object calledFrom)
{
     boolean ret = true;
     if(fromdate == datenull())
          ret = checkfailed('From Date Must Be Entered');

     return ret;
}
public Query initQuery(Query _query)
{
     QueryBuildDataSource queryBuildDataSource;
     QueryBuildRange queryBuildRange;
     ;
     //memberikan nilai default pada query selection/range
     queryBuildDataSource = _query.dataSourceTable(tablenum(InventTable));
     queryBuildDataSource.clearRange(fieldnum(InventTable, ItemGroupId));
     queryBuildRange = queryBuildDataSource.findRange(fieldnum(InventTable, ItemGroupId));
     if(!queryBuildRange)
          queryBuildRange = queryBuildDataSource.addRange(fieldnum(InventTable, ItemGroupId));
     queryBuildRange.value('RM_ES,RM_MM,RM_PC');

     return _query;
}