过账单一订单的方法请参考:http://blog.csdn.net/AXWolfer/archive/2010/04/20/5506438.aspx 汇总过账代码: static void BookMultipleSO(Args _args) { SalesFormLetter salesFormLetter; SalesParmTable salesParmTable; SalesTable salesTable; SalesParmUpdate salesParmUpdate; DocumentStatus enum = DocumentStatus::PackingSlip;//set enum to the specific book type you need Query query; QueryBuildDataSource qbds; QueryBuildRange qbr; ParmId parmId; ; salesFormLetter = SalesFormLetter::construct(enum); salesFormLetter.allowEmptyTable(true); salesFormLetter.resetParmListCommonCS(); salesFormLetter.transDate(systemdateget()); if(CustParameters::find().SalesCycle) { salesFormLetter.parmSalesPurchCycleAction(SalesPurchCycle::salesPurchCycleAction(enum)); } salesFormLetter.enableUpdateNowField(true); salesFormLetter.lockSalesUpdateField(false); salesFormLetter.prePromptInit(); salesFormLetter.lateSelectionRemoveLines(); salesFormLetter.updateQueryBuild();//this call will setup the queryrun chooseLines salesFormLetter.queryChooseLines().interactive(false); // Note: the chooseLines variable in FormLetter is a queryRun // in SalesFormLetter.initQueryBuild() you can found this chooseLines // is initialized like this: chooseLines = new SysQueryRun(querystr(SalesUpdate)); qbds = salesFormLetter.queryChooseLines().query().dataSourceTable(tablenum(SalesTable)); // add filter, this filter will help us to select those SO which need to be posted qbr = SysQuery::findOrCreateRange(qbds, fieldnum(SalesTable, SalesId)); if (qbr) { qbr.value("SO-100636,SO-100637"); } salesFormLetter.createParmUpdate();// create SalesParmUpdate record in SalesFormLetter salesFormLetter.specQty(SalesUpdate::All);// the qty to be posted salesFormLetter.sumBy(AccountOrder::Account);// how to sum salesFormLetter.chooseLines();// this call will insert data into those parm tables,eg salesParmTable salesFormLetter.run();// post info ("finish"); }