我需要修改採購訂單,因此用戶可以選擇和保存PO爲PDF在目標文件夾導出報表爲PDF AX 2012 CU10
我創建了一個新的按鈕,讓用戶選擇數據和點擊後按鈕,系統會創建一個PDF文件並將其保存到目標文件夾。
這是我的代碼
public static void main(Args _args)
{
PurchTable purchTable,purchTable2, row;
PurchPurchaseOrderController purchPurchaseOrderController ;
PurchPurchaseOrderContract purchPurchaseOrderContract;
SrsReportRunImpl srsReportRun;
VendPurchOrderJour vendPurchOrderJour;
FormDataSource purchTable_ds;
str PDFName;
int tot = 0;
Args args ;
ReportName reportName = "PurchPurchaseOrder.ReportPRI";
;
if(_args.record().TableId == tableNum(PurchTable))
{
purchTable2 = _args.record();
purchTable_ds = purchTable2.dataSource();
}
if (purchTable_ds.anyMarked())
{
row = purchTable_ds.getFirst(1, false);
info("a1");
while(row)
{
tot++;
info(row.PurchId);
args = new Args();
args.record(row);
select firstFast purchTable where purchTable.RecId == row.RecId ;
select firstFast vendPurchOrderJour where vendPurchOrderJour.PurchId == purchTable.PurchId ;
PDFName = strFmt("C:\\SharePDF\\%1.pdf",strReplace(purchTable.PurchId,'/','_'));
purchPurchaseOrderController = new PurchPurchaseOrderController();
purchPurchaseOrderController.parmReportName(ReportName);
purchPurchaseOrderContract = purchPurchaseOrderController.parmReportContract().parmRdpContract();
purchPurchaseOrderContract.parmRecordId(vendPurchOrderJour.RecId);
purchPurchaseOrderController.parmArgs(args);
srsReportRun = purchPurchaseOrderController.parmReportRun() as SrsReportRunImpl;
purchPurchaseOrderController.parmReportRun(srsReportRun);
purchPurchaseOrderController.parmReportContract().parmReportExecutionInfo(new SrsPrintMgmtExecutionInfo());
purchPurchaseOrderController.parmReportContract().parmPrintSettings().printMediumType(SRSPrintMediumType::File);
purchPurchaseOrderController.parmReportContract().parmPrintSettings().overwriteFile(true);
purchPurchaseOrderController.parmReportContract().parmPrintSettings().fileFormat(SRSReportFileFormat::PDF);
purchPurchaseOrderController.parmReportContract().parmPrintSettings().fileName(PDFName);
purchPurchaseOrderController.runReport();
row = purchTable_ds.getNext();
}
}
info(strFmt("%1",tot));
}
此代碼運行,將創建一個PDF文件,但只在最後PO。
任何建議如何解決這個問題?謝謝
,如果你在這行代碼debugg:'行= purchTable_ds.getFirst(1,假);'獲得第一PO或得到一個不正確的值? –
它得到最後的採購訂單。 – julius
嘗試使用[MultiSelectionHelper](https://msdn.microsoft.com/en-us/library/multiselectionhelper.aspx)類。 [通過MultiSelectionHelper類獲取精選記錄](http://mafsarkhan.blogspot.de/2013/05/get-select-records-by.html)是許多關於如何使用它的教程之一。 –