Inventory Transfer journal in AX 2009 by Raspberry Pi 3 Model B+

Inventory Transfer

The solution is used in production floor to transfer items between warehouses. It uses barcode scanner connected to Raspberry Pi 3 Model B+ [1] with 7'' TouchScreen. The device communicates through the wireless network to Windows Service. The Windows Service through .NET Business Connector uses AX 2009 static function to process the requests.


static str insertTransferJournalLine(str _devId, str _devName, InventJournalId _journalNumber, InventLocationId _warehouseFrom, InventLocationId _warehouseTo, ItemId _item, inventBatchId _batch, inventSerialId _serial, str _quantity)
{
InventDim inventDimFrom, inventDimTo;
InventJournalTable inventJournalTable;
InventJournalTrans inventJournalTrans;
NumberSeq numberSeq;
b_BizConService log;
str ret = "";
;
ttsbegin;
if(_journalNumber != "") // try to use existing journal
{
inventJournalTable = InventJournalTable::find(_journalNumber, true);
if(inventJournalTable) // found such journal
{
if(inventJournalTable.Posted == NoYes::Yes)
{
ret = strfmt("Journal %1 is posted", inventJournalTable.JournalId);
}
}
else
{
ret = strfmt("Journal %1 is not found", _journalNumber);
}
}
else // create new journal
{
inventJournalTable.clear();
inventJournalTable.initValue();
inventJournalTable.initFromInventJournalName(InventJournalName::find("J-STK"));
inventJournalTable.insert();
}
if(ret == "") // if no errors so far, insert line
{
inventDimFrom.InventLocationId = _warehouseFrom;
inventDimFrom.inventBatchId = _batch;
inventDimFrom.inventSerialId = _serial;
inventDimFrom.wMSLocationId = "DEFAULT";
inventDimFrom = InventDim::findOrCreate(inventDimFrom);
//
inventDimTo.InventLocationId = _warehouseTo;
inventDimTo.inventBatchId = _batch;
inventDimTo.inventSerialId = _serial;
inventDimTo.wMSLocationId = "DEFAULT";
inventDimTo = InventDim::findOrCreate(inventDimTo);
//
inventJournalTrans.clear();
inventJournalTrans.initValue();
inventJournalTrans.initFromInventJournalTable(inventJournalTable);
inventJournalTrans.ItemId = _item;
inventJournalTrans.Qty = str2num(_quantity)*(-1);
inventJournalTrans.InventDimId = inventDimFrom.inventDimId;
inventJournalTrans.ToInventDimId = inventDimTo.inventDimId;
inventJournalTrans.insert();
//
InventJournalTable::initTotal(inventJournalTable);
inventJournalTable.update();
}
ttscommit;
ret = strfmt("OK:%1", inventJournalTable.JournalId);
//
log.initValue();
log.devId = _devId;
log.devName = _devName;
log.JournalId = strfmt("%1", inventJournalTable.JournalId);
log.Command = strfmt("%1,%2,%3,%4,%5,%6", _warehouseFrom, _warehouseTo, _item, _batch, _serial, _quantity);
log.Result = ret;
log.insert();
return ret;
}

[1] https://www.raspberrypi.org
[2] Source code for Raspberry Pi device https://github.com/dzoka/InventoryTransfer