Having trouble with inventJournalTrans.Qty

Hey all,

I’ve created a job to import part numbers from an excel file, it contains, Part ID,FROM and TO warehouses and locations, and quantity to be transferred. It creates a Transfer Journal and adds all the lines with the information from excel just fine with the exception on the quantity field. It’s leaving that field in the journal lines completely empty. I’m having trouble with the inventJournalTrans.Qty field. My guess is that this field does not like strings and I need to somehow convert my variable “Quantity” to something else. Any help would be fantastic! Thanks… My code is as follows…

static void CreateTransferJournal(Args _args)

{

InventJournalTable inventJournalTable;

InventJournalTrans inventJournalTrans;

InventJournalCheckPost inventJournalCheckPost;

NumberSeq num;

boolean _throwserror=true;

boolean _showinforesult=true;

InventDim frominventDim,ToinventDim;

SysExcelApplication application;

SysExcelWorkbooks workbooks;

SysExcelWorkbook workbook;

SysExcelWorksheets worksheets;

SysExcelWorksheet worksheet;

SysExcelCells cells;

COMVariantType type;

int row;

ItemId itemid;

Name from_warehouse;

Name from_location;

Name to_warehouse;

Name to_location;

Name Quantity;

FileName filename;

;

ttsbegin;

/////////////////////////////////////////////////////////////

/////Begin Inputting into Journal///////////////////////////

inventJournalTable.clear();

num = new NumberSeq();

num = NumberSeq::newGetNum(InventParameters::numRefTransferId());

inventJournalTable.initFromInventJournalName(InventJournalName::find(InventParameters::find().TransferJournalNameId));

inventJournalTable.Description = “Inventory Transfer Journal”;

inventJournalTable.SystemBlocked = false;

inventJournalTable.insert();

info(“Entry Inserted”);

info(strfmt(“The Voucher generated is %1”,inventJournalTable.JournalId));

//////////////////////////////////////////////////////////////////

///////////////////Grab Data from Excel///////////////////////////

application = SysExcelApplication::construct();

workbooks = application.workbooks();

//specify the file path that you want to read

filename = “C:\Temp\Parts Upload.xls”;

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();

row++;

do

{

row++;

itemId = cells.item(row, 1).value().bStr();

from_warehouse = cells.item(row, 2).value().bStr();

from_location = cells.item(row,3).value().bStr();

to_warehouse = cells.item(row, 4).value().bStr();

to_location = cells.item(row,5).value().bStr();

Quantity = cells.item(row,6).value().bStr();

type = cells.item(row+1, 1).value().variantType();

////////////Create new journal line//////////////////////

inventJournalTrans.clear();

inventJournalTrans.initFromInventJournalTable(inventJournalTable);

inventJournalTrans.ItemId = itemId;

frominventDim.InventLocationId=from_warehouse;

frominventDim.wMSLocationId=from_location;

frominventDim.inventSiteId =“10”;

ToinventDim.InventLocationId = to_warehouse;

ToinventDim.wMSLocationId = to_location;

ToinventDim.InventSiteId = “10”;

ToinventDim = InventDim::findOrCreate(ToinventDim);

frominventDim = InventDim::findOrCreate(frominventDim);

inventJournalTrans.InventDimId = frominventDim.inventDimId;

inventJournalTrans.initFromInventTable(InventTable::find(itemId));

inventJournalTrans.Qty = Quantity;

inventJournalTrans.ToInventDimId = ToinventDim.inventDimId;

inventJournalTrans.TransDate = SystemDateget();

inventJournalTrans.insert();

}

while (type != COMVariantType::VT_EMPTY);

application.quit();

////////////////////////////////////////////////////////////////////////////

////Post the journal/////////////////////////////////////////////////

/*inventJournalCheckPost = InventJournalCheckPost::newJournalCheckPost(JournalCheckpostType::Post,inventJournalTable);

inventJournalCheckPost.parmThrowCheckFailed(_throwserror);

inventJournalCheckPost.parmShowInfoResult(_showinforesult);

inventJournalCheckPost.run();

inventJournalTable.SystemBlocked = false;

inventJournalTable.update();

*/

ttscommit;

}