AX Query分页

 1 static void Job_Testing(Args _args)
 2 {
 3     Query            query = new Query();
 4     QueryBuildDataSource qbds;
 5     QueryRun          qr;
 6     TableID           tableId;
 7     int               icount = 0;
 8     ;
 9     tableid = tablename2id('CustTable');
10     qbds = query.addDataSource(tableId);
11     
12     //IMPORTANT: Order by item id
13     qbds.addOrderByField(fieldname2id(tableid,'AccountNum'));
14     qr = new QueryRun(Query);
15     
16     //IMPORTANT:  Enable position paging for the queryrun object
17     qr.enablePositionPaging(true);
18 
19   //IMPORTANT: Add a range by providing the parameters as starting record number and number of records
20     qr.addPageRange(1,1);
21     while (qr.next())
22     {
23         icount++;
24     }
25     print icount;
26     pause;
27 }
posted @ 2012-08-27 16:25  Sprite.z  Views(421)  Comments(0Edit  收藏  举报