@Crispin Thank for your reply.
below is the class method i am using for upload.
public void movementJournalUpload(Args _args)
{
InventJournalTrans InventJournalTrans;
InventDim InventDim;
int dec=0, Line=1;
ItemId ItemId;
InventDimId InventDimId;
BOMQty Qty;
WrkCtrConsumption WrkCtrConsumption;
ItemId UnitId;
EcoResItemConfigurationName configId;
ConfigGroupId ConfigGroupId;
EcoResItemColorName InventColorId;
InventLocationId InventLocationId;
EcoResItemStyleName InventStyleid;
InventSiteId InventSiteId;
EcoResItemSizeName InventsizeId;
InventBatchId InventBatchId;
InventSerialId InventSerialId;
WMSLocationId WMSLocationId;
BOMQtySerie BOMQtySerie;
ItemCostPrice CostPrice;
CostAmount CostAmount;
TransDate TransDate;
MainAccountNum offsetAccount;
int64 st;
DimensionValue Department;
DimensionValue Project;
DimensionValue costCenter;
container offSetPattern;
InventBatch inventBatch;
InventSerial inventSerial;
WMSLocation location;
WMSAisle aisle;
Dialog dialog;
Filename filename;
DialogField dialogFilename;
//To filter the files while selecting
container conFilter = ["Microsoft Excel 97-2003 Worksheet (.xls)" ,"*.xlsx"];
//Excel
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
COMVariantType type;
int row=1;
application = SysExcelApplication::construct();
workbooks = application.workbooks();
InventJournalTrans = _args.record();
dialog = new dialog();
dialog.caption("select a file");
dialogFilename = dialog.addField(extendedTypeStr(FilenameOpen));
//To filter the files while selecting
dialog.filenameLookupFilter(conFilter);
dialog.run();
if(dialog.closedOk())
{
filename = dialogFileName.value();
}
try
{
workbooks.open(filename);
}
catch (Exception::Error)
{
throw error("File cannot be opened.");
}
workbook = workbooks.item(1);
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1);
cells = worksheet.cells();
try
{
ttsBegin;
do
{
row++;
TransDate = cells.item(row,1).value().date();
ItemId = cells.item(row,2).value().bStr();
InventsizeId = cells.item(row,3).value().bStr();
InventColorId = cells.item(row,4).value().bStr();
InventStyleid = cells.item(row,5).value().bStr();
InventSiteId = cells.item(row,6).value().bStr();
InventLocationId = cells.item(row,7).value().bStr();
InventBatchId = cells.item(row,8).value().bStr();
WMSLocationId = cells.item(row,9).value().bStr();
InventSerialId = cells.item(row,10).value().bStr();
Qty = cells.item(row,11).value().double();
CostPrice = cells.item(row,12).value().double();
CostAmount = Qty * CostPrice;//cells.item(row,13).value().double();
offsetAccount = cells.item(row,14).value().bStr();//cells.item(row,14).value().bStr();
Department = cells.item(row,15).value().bStr();
Project = cells.item(row,16).value().bStr();
costCenter = cells.item(row,17).value().bStr();
configId = cells.item(row,18).value().bStr();
if(InventTable::find(ItemId))
{
InventDim.InventSiteId = "10";//InventSiteId;
InventDim.InventSizeId = InventsizeId;
InventDim.InventColorId = InventColorId;
InventDim.InventLocationId = InventLocationId;
InventDim.wMSLocationId = WMSLocationId;
InventDim.configId = configId;
inventDim = InventDim::findOrCreate(inventDim);
InventJournalTrans.InventDimId = inventDim.inventDimId;
InventJournalTrans.TransDate = TransDate;
InventJournalTrans.ItemId = ItemId;
InventJournalTrans.Qty = Qty;
InventJournalTrans.CostPrice = CostPrice;
InventJournalTrans.CostAmount = decRound(InventJournalTrans.CostPrice * InventJournalTrans.Qty,2);// CostAmount;
InventJournalTrans.LineNum = line;
offSetPattern = [offsetAccount, offsetAccount, 0];
InventJournalTrans.LedgerDimension = AxdDimensionUtil::getLedgerAccountId(offSetPattern);
InventJournalTrans.DefaultDimension = InventTable::find(ItemId).DefaultDimension;//this.getDefaultDimension(Department,"",Project,"",costCenter);
InventJournalTrans.insert();
line++;
}
else
{
info(strFmt("No Item %1 in AX", ItemId));
}
type = cells.item(row+1, 1).value().variantType();
}
while(type != COMVariantType::VT_EMPTY);
ttsCommit;
}
catch
{
info(strFmt("Problem with Item %1", ItemId));
}
workbooks.close();
application.quit();
info("Operation/Processing Completed");
}