jeudi 29 décembre 2011

How to override fetch method in a report

here is an example of an overrided fetch method in a report  
----------------------------------------------classDeclaration-----------------------------------------
public class ReportRun extends RunbaseReport
{
     InventQty                  sumQty1, sumQty2, sumQty3, sumQty4, sumQty5, sumQty6,
                                sumQty7, sumQty8, sumQty9, sumQty10, sumQty11, sumQty12, sumQty13, sumQty14;

     InventTrans                inventTrans;
     Thy_IntrastatItemCode      thy_IntrastatItemCode;
     IntrastatItemCode          intrastatItemCode;
     DialogField                fieldFromDate_Period;
     DialogField                fieldToDate_Period;
     FromDate                   fromDate;
     ToDate                     toDate;

     #define.CurrentVersion(1)

     #localmacro.CurrentList
        fromDate,
        toDate
     #endmacro
}

----------------------------------------------dialog----------------------------------------------------
public Object dialog(Object _dialog)
{
    DialogRunbase dialog = _dialog;
    ;

    dialog.addGroup("@SYS94817");
    fieldFromDate_Period  = dialog.addField(typeid(FromDate));
    fieldToDate_Period    = dialog.addField(typeid(ToDate));
    fieldFromDate_Period.value(fromDate);
    fieldToDate_Period.value(toDate);
    return dialog;
}

---------------------------------------------getDialog------------------------------------------------
boolean getFromDialog()
{;
    fromDate = fieldFromDate_Period.value();
    toDate   = fieldToDate_Period.value();
    return true;

----------------------------------------------fetch-----------------------------------------------------
public boolean fetch()
{
    boolean                 ret = false;
    QueryRun                _queryRun;
    queryBuildDataSource    queryBuildDataSource;
    ;

    _queryRun = new QueryRun(element);
            _queryRun.query().datasourcetable(tablenum(Thy_InventCustomsTrans)).addrange(fieldnum(Thy_InventCustomsTrans,DeliveryDate)).
    value(queryrange(fromDate,toDate));


     if (! _queryRun.prompt())
     {
        return ret;
     }

     while (_queryRun.next())
     {
        Thy_InventCustomsTrans  = _queryRun.get(tablenum(Thy_InventCustomsTrans));

        While select Qty, ItemId, InventTransId, inventDimId, RecId from inventTrans
        {
              sumQty1    = sumQty1 + inventTrans.Qty;            
        }
        element.send(Thy_InventCustomsTrans);
     }
    ret = true;

    return ret;
}
------------------------------------------------pack----------------------------------------------------
public container pack()
{
    return [#CurrentVersion, #CurrentList];
}
---------------------------------------------unpack-----------------------------------------------------
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;
    }
    return _ret;
}


Here is another example

public boolean fetch()
{
querybuildrange  qbr;
QueryRun qr = new queryrun(this.query());// picks the current datasource available in the report
;

qr.query().datasourcetable(tablenum(RBOTransactionTable)).addrange(fieldnum(RBOTransactionTable,TransDate)).value(queryrange(fromDate,toDate));

while(qr.next())
{

element.send(RBOStoreTable);
element.send(RBOTransactionTable);
element.send(RBOTransactionSalesTrans);

}

return true;
}

Here is another example from MSDN tutorials
http://msdn.microsoft.com/en-us/library/bb395110%28v=ax.10%29.aspx  

Check the RunBase Framework here  
http://msdn.microsoft.com/en-us/library/aa863262.aspx 

Aucun commentaire:

Enregistrer un commentaire