AX2012: Mark a InventTrans (salesline) up against a InventTrans (purchline)

I hope that this is the right place to ask this question.
Otherwise, I kindly ask You direct me to an appropriate place.

I need a piece of code that marks a salesLine up against a purchased party (purchLine). I have found several examples solving the problem on AX2009, but I haven’t succeeded porting the code to AX2012.

I have by code created the SalesTable, SalesLine and the InventTrans, that vil reserve/draw the items from the stock, and I have found the InventTrans, that comes from the PurchLine. How can I by code mark the quantity of items I want to reserve/draw from that purch-inventtrans?

Best regards Ebbe

I have tried to rewrite the code, I have found til AX2009:

Static void TEST_InventTransMarking(Args args)
InventTransOrigin purchLineTransOrigin;
InventTrans purchLineTrans;
InventTransOrigin salesLineTransOrigin;
InventTrans salesLineTrans;
TmpInventTransMark tmpInventTransMark;
TmpInventTransMark tmpInventTransMarkNow;
Map mapMarkNow;
InventDimId inventDimId;
InventDim inventDim;
MapEnumerator mapEnumerator;
container con;
Qty qty;
salesLineTransOrigin = InventTransOrigin::findByInventTransId(‘000362_300’, true);
salesLineTrans = InventTrans::findByInventTransOrigin(salesLineTransOrigin.RecId);

purchLineTransOrigin = InventTransOrigin::findByInventTransId(‘000321_300’, false);
purchLineTrans = InventTrans::findByInventTransOrigin(purchLineTransOrigin.RecId);

inventDimId = salesLineTrans.inventDimId;
inventDim = InventDim::find(inventDimId);

[con, qty] = TmpInventTransMark::packTmpMark(salesLineTransOrigin, inventDim, salesLineTrans.Qty);

mapMarkNow = Map::create(con);
mapEnumerator = mapMarkNow.getEnumerator();

while (mapEnumerator.moveNext())
tmpInventTransMark = mapEnumerator.currentValue();
if (tmpInventTransMark.InventTransOrigin == purchLineTransOrigin.RecId)

buf2buf(tmpInventTransMark, tmpInventTransMarkNow);
tmpInventTransMarkNow.qtyMarkNow = -1;


mapMarkNow = new Map(Types::Integer, Types::Record);
mapMarkNow.insert(tmpInventTransMarkNow.RecId, tmpInventTransMarkNow);
TmpInventTransMark::updateTmpMark(salesLineTrans.InventTransOrigin, inventDim, salesLineTrans.Qty, mapMarkNow.pack());

All is doing well until I execute the last statement: updateTmpMark(…
It returns with following infolog:

Warning Message (…) Transaction has been changed.
Error Message (…) Update has been canceled.

Can anyone explain these two messages?