|
15.12.2014, 18:39 | #1 |
Banned
|
Потому как взорвать еще надо:
ReqPlannedOrder::construct().insertFromForm() Цитата:
reqCalcExplodePo = this.getReqCalcExplode(reqTransPo);
reqCalcExplodePo.parmRecalculateBomLevels(_recalculateBomLevels); reqCalcExplodePo.run(); |
|
15.12.2014, 21:05 | #2 |
Участник
|
Итог! Будет все так::
X++: static void _HTC_EXCELIMPORT_DataImportToAXFromExcel(Args _args) { SysExcelApplication xlsApplication; SysExcelWorkBooks xlsWorkBookCollection; SysExcelWorkBook xlsWorkBook; SysExcelWorksheets xlsWorkSheetCollection; SysExcelWorksheet xlsWorkSheet; SysExcelRange xlsRange; SysExcelCells Cells; SysExcelCell RCell; CommaIO inFile; int nRow,i; DialogField dialogPath; DialogField dlgFilepath; DialogField dlgReqPlanId; DialogField dlgInventSiteId; Dialog dialog; Filename filename; ItemId ItemId; ItemGroupId ItemGroupId; ItemBomId ItemBomId; ItemRouteId itemRouteId; InventSiteId inventSiteId; ReqPO ReqPo; ReqTrans ReqTrans; ReqPlanId ReqPlanId; ReqCalcExplodePo reqCalcExplodePo; ReqDate ReqDate; ReqDateOrder ReqDateOrder; Qty Qty; InventDim InventDim; ; dialog = new Dialog("Import"); dialogPath = dialog.addField(typeid(Filenameopen), "File Name"); dlgReqPlanId = dialog.addField(typeid(ReqPlanId), "Plan Id"); dlgInventSiteId = dialog.addField(typeid(InventSiteId), "Site"); dialog.run(); if (dialog.run()) { filename = (dialogPath.value()); ReqPlanId = dlgReqPlanId.value(); InventSiteId = dlgInventSiteId.value(); } inFile = new CommaIO (filename, 'R'); if (!inFile || infile.status() != IO_Status::Ok ) { throw error (strfmt("@SYS19312",filename)); } try { xlsApplication = SysExcelApplication::construct(); xlsWorkBookCollection = xlsApplication.workbooks(); xlsWorkBookCollection.open(filename); xlsWorkSheetCollection = xlsApplication.worksheets(); xlsWorkSheet = xlsWorkSheetCollection.itemFromNum(1); Cells = xlsWorkSheet.Cells(); nRow = 2; RCell = Cells.Item(nRow, 1); InventDim.InventSiteId = InventSiteId; while(RCell.value().bStr() != "") { ItemId = RCell.value().bStr(); RCell = Cells.item(nRow,2); Qty = RCell.value().double(); ttsbegin; ReqPO.ReqPlanId = ReqPlanId; ReqPO.RefType = ReqRefType::BOMPlannedOrder; ReqPO.initFromItemId(ItemId); ReqPo.setBOMCreated(true); ReqPo.setRouteCreated(true); ReqPO.Qty = Qty; ReqPo.BOMRouteCreated = ReqBOMRouteCreated::BOMRoute; Reqpo.CovInventDimId = InventDim::findOrCreate(inventDim).inventDimId; ReqPO.PurchUnit = inventTableModule::find(ItemId,moduleInventPurchSales::Invent).UnitId; ReqPo.ReqTime = timenow(); ReqPo.ReqDateDlv = today(); ReqPo.ReqDateOrder = today(); ReqPo.insert(); ReqTrans.insertFromReqPo(ReqPo,True); ttscommit; reqCalcExplodePo = ReqCalcExplode::newReqTrans(ReqTrans, null); ReqCalcExplodePo.run(); nRow++; RCell = Cells.Item(nRow, 1); } xlsApplication.quit(); xlsApplication.finalize(); info("Imported completed"); } catch( Exception::Error) { //Close Excel. xlsApplication.quit (); xlsApplication.finalize (); ttsabort; info("Unable to process the excel import "); } } |
|
15.12.2014, 22:49 | #3 |
Участник
|
Class_DryRuImportPOFromExcel.xpo
Сделал на базе RunBaseBatch. |
|
|
За это сообщение автора поблагодарили: AlGol (1). |