Dynamics AX Knowledge

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

    SalesLine               _salesLine;
    InventTable             _inventTable ;
    int                     a =0 ;
    
Query                query      = new Query() ;
    QueryRun             qr         = new queryRun(query) ;
    QueryBuildDataSource qbds       = qr.query().addDataSource(tableNum(SalesLine)) ;
    QueryBuildRange      qbrSalesId   = qbds.addRange(fieldNum(SalesLine,SalesId)) ;
    QueryBuildFieldList  qbfl       = qbds.fields() ;
    ;
    qbrSalesId.value('SO-I-012482');
    //The below 4 lines is to use group by
    qbds.orderMode(OrderMode::GroupBy);
    
qbfl.addField(fieldNum(SalesLine,SalesQty),SelectionField::Sum);
    
qbfl.addField(fieldNum(SalesLine,SalesQty));
    qbds.addSortField(fieldnum(SalesLine,Name));
    //The below 2 lines is to use order by
//qbds.orderMode(OrderMode::OrderBy);
//qbds.addSortField(fieldnum(SalesLine,ItemId));

    if (qr.prompt())
    {
        while (qr.next())
        {
            _salesLine     = qr.get(tableNum(SalesLine));
        
    a       =  a  + 1  ;
            print   _salesLine.SalesId,'-----',_salesLine.ItemId,'-----',_salesLine.Name,'-----',a ;
        }
    
}
    pause;

posted on 2007-12-12 17:35  Jacky Xu  阅读(347)  评论(0编辑  收藏  举报