Dears,
I'm trying to import Inventory Transfer journal with below job. But it gives me warning Inventory dimension identification not specified. Please let me know how to solve this issue.
static void InventoryImportJob(Args _args)
{
InventJournalTable journalTable;
InventJournalTrans journalTrans;
InventJournalTableData journalTableData;
InventJournalTransData journalTransData;
InventTable inventTable;
InventDim locInventDim, _inventDim;
Counter cnt;
ItemIdInventoried Itemid;
InventSiteId inventSiteId, toInventSiteId;
InventLocationId inventLocationId, toInventLocationId;
InventBatchId inventBatchId;
InventQtyJournal qty;
ItemCostPrice costprice;
LedgerDimensionDefaultAccount mainacc;
str 20 mainaccStr;
container offSetEntryPattern;
LedgerJournalId JournalId;
Description BusinessUnit;
DimensionDefault defaultDim;
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
COMVariantType type;
FilenameOpen filename;
dialogField dialogFilename;
Dialog dialog;
Integer row = 1;
int coun;
Mainaccount mainaccount;
int _mainaccountnum; //= "111200";//"202000";
Ledger ledger;
CompanyInfo companyinfo;
str COMVariant2Str(COMVariant _cv)
{
switch (_cv.variantType())
{
case (COMVariantType::VT_BSTR):
return _cv.bStr();
case (COMVariantType::VT_R8):
// return _cv.toString() ;
return _cv.bStr() ;
case (COMVariantType::VT_DATE):
return date2str(_cv.date(),123,2,1,2,1,4);
case (COMVariantType::VT_EMPTY):
return '';
default:
throw error(strfmt("@SYS26908", _cv.variantType()));
}
}
;
dialog = new Dialog('Import Details');
dialogFilename = dialog.addField(ExtendedTypeStr("FilenameOpen"));
dialog.filenameLookupTitle('Import from excel.');
dialog.caption('Import From Excel');
dialogFilename.value(filename);
if(dialog.run())
{
filename = dialogFilename.value();
application = SysExcelApplication::construct();
workbooks = application.workbooks();
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++;
JournalId = "";
JournalId = cells.item(row, 7).value().bStr();
Select journalTable Where journalTable.JournalId == JournalId ;
itemId = cells.item(row, 1).value().bStr();
inventSiteId = cells.item(row, 2).value().bStr();
inventLocationId = cells.item(row, 3).value().bStr();
qty = cells.item(row, 4).value().double();
toInventSiteId = cells.item(row, 5).value().bStr();
toInventLocationId = cells.item(row, 6).value().bStr();
type = cells.item(row+1, 1).value().variantType();
locInventDim.inventBatchId = inventBatchId;
locInventDim.InventSiteId = inventSiteId;
locInventDim.InventLocationId = inventLocationId;
_inventDim.InventSiteId = toInventSiteId;
_inventDim.InventLocationId = toInventLocationId;
journalTrans.clear();
journalTrans.initFromInventJournalTable(journalTable);
journalTrans.TransDate = cells.item(row, 8).value().date();//systemDateGet();
journalTrans.ItemId = itemId;
journalTrans.JournalId = journalTable.JournalId;//JournalId;//
journalTrans.InventDimId = InventDim::findOrCreate(locInventDim).inventDimId;
journalTrans.Qty = qty;
journalTrans.insert();
coun++;
print(coun);
}
while (type != COMVariantType::VT_EMPTY);
info(int2str(coun));
ttscommit;
application.quit();
}
catch
{
throw error('Error in import.');
}
}
}
*This post is locked for comments
I have the same question (0)