I have to populate 2 fields in AX, ID and TimeOff .
One is integer and another is decimal number. I have defined the table field . Id Int and TimeOff as real.
How can I upload data into table. I am getting error "Argument 'TimeOff' is incompatible with the required type." at the line in red color in my class.
What should my definition for real numbers be?
this.updateHcmWorker(this.COMVariant2Str(cells.item(row,any2real(map.lookup("ID"))).value()),this.COMVariant2Str(cells.item(row,any2real(map.lookup("TimeOff"))).value()));
Here is my code
private void readExcel(str _filePath)
{
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
COMVariantType type;
int row;
int column;
Struct struct,structOffset;
Map map = new Map(Types::String, Types::Integer);
str 100 columName;
LedgerJournalId journalid;
;
struct = new Struct();
structOffset = new Struct();
try
{
row = 1;
column = 1;
if(WinAPI::fileExists(_filePath))
{
application = SysExcelApplication::construct();
workbooks = application.workbooks();
try
{
workbooks.open(_filePath);
}
catch
{
throw error("@AAM49");
}
workbook = workbooks.item(1);
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1);
cells = worksheet.cells();
do
{
columName = cells.item(row,column).value().bStr();
map.insert(columName,column);
type = cells.item(row, column+1).value().variantType();
column++;
}
while(type != COMVariantType::VT_EMPTY);
do
{
try
{
row++;
this.updateHcmWorker(this.COMVariant2Str(cells.item(row,any2real(map.lookup("ID"))).value()),this.COMVariant2Str(cells.item(row,any2real(map.lookup("TimeOff"))).value()));
}
catch
{
throw error("@AAM54");
}
type = cells.item(row+1,any2int(map.lookup("ID"))).value().variantType();
}
while(type != COMVariantType::VT_EMPTY);
application.quit();
info("Done");
}
else
{
application.quit();
}
}
catch
{
application.quit();
}
}