lundi 19 septembre 2011

How to sort fields in a report

Here is an example to do it, in the report WMSPickingList_OrderPick we have in the fetch method :

  QueryRun                queryRunWMSOrderTrans;

  queryRunWMSOrderTrans = new QueryRun(element.initQueryWMSOrderTrans());



the initQueryWMSOrderTrans method is defined as follows :

Query initQueryWMSOrderTrans()
{
    Query                                 queryWMSOrderTrans;
    QueryBuildDataSource       qbds;
    QueryBuildRange                qbr_status;
    ;

    queryWMSOrderTrans = new Query();
    qbds = queryWMSOrderTrans.addDataSource(tablenum(WMSOrderTrans));

    WMSOrderTrans::queryAddSortDefault(qbds);

    qbr_status  = qbds.addRange(fieldnum(WMSOrderTrans,ExpeditionStatus));
    qbr_status.value(range);

    return queryWMSOrderTrans;
}

the queryAddSortDefault method is defined as follows in the methods of WMSOrderTrans, I needed to sort fields in the report according to Thy_WMSPalletId value : in the ascending order and  Thy_WMSpackageIdBasis field also in the ascending order ( I  have already added these two fields in the table WMSOrderTrans )

// Changed on 19 Sep 2011 at 11:45:07 by iba
static public void queryAddSortDefault(QueryBuildDataSource    _qbS,
                                       OrderMode               _orderMode = OrderMode::OrderBy)
{
    _qbS.sortClear();
    _qbS.orderMode(_orderMode);

    //<iba>
    _qbS.addSortField(fieldnum(WMSOrderTrans, Thy_WMSPalletId),SortOrder::Ascending);
    _qbS.addSortField(fieldnum(WMSOrderTrans, Thy_WMSpackageIdBasis),SortOrder::Ascending);

    //</iba>

    _qbS.addSortField(fieldnum(WMSOrderTrans, RouteId));
    _qbS.addSortField(fieldnum(WMSOrderTrans, IsReserved),SortOrder::Descending);//un-reserved should end up in the bottom

    _qbS.addSortField(fieldnum(WMSOrderTrans, ItemSortCode));
    _qbS.addSortField(fieldnum(WMSOrderTrans, SortCode));
    _qbS.addSortField(fieldnum(WMSOrderTrans, ItemId));

    _qbS.addSortField(fieldnum(WMSOrderTrans, ItemTagging));
    _qbS.addSortField(fieldnum(WMSOrderTrans, CaseTagging));
}

Aucun commentaire:

Enregistrer un commentaire