Dynamics AX Blog - Posts from 2015 - Page 4
These posts are machine-translated.
Currently, only posts from »2015« are displayed
Find number sequence code based on Exteneded data typeI recently had a problem with a number sequence in a form. But i didn't know the name of the number sequence, so i was not able to look for it in the number sequence code form. info(strFmt("%1", NumberSequenceTable::find( NumberSeqReference::findReference( extendedTypeNum(PurchReqId)).NumberSequenceId).NumberSequence)); |
Reserve/Unreserve a sales order lineThe are a lot of examples about how to reserve a sales order line. But i did not find an example, where the result of the reservation has been tested. So i had to write some code for my own. I am checking the reserved value before executing my code, and afterwards. If the reserved quantity is still the same, my job seems to have failed. static void reserveSalesLine(Args _args) { InventTransIdSumSingleStatus inventTransIdSumSingleStatus; SalesLine salesLine; InventMovement inventMovement; InventDim inventDim; InventDimParm inventDimParmCriteria; InventQtyReservPhysical oldReservedQty; InventQtyReservPhysical newReservedQty; InventUpd_Reservation inventUpd_Reservation; InventQty reserveQty; // Inline method to get current reserved quantity for specific inventDim InventQtyReservPhysical getReservedQty() { inventDimParmCriteria.initFromInventDim(inventDim); inventTransIdSumSingleStatus = InventTransIdSumSingleStatus::newTransOriginIdStatus(InventTransOriginSalesLine::findInventTransOriginId(salesLine.DataAreaId, salesLine.InventTransId), StatusReceipt::None, StatusIssue::ReservPhysical); inventTransIdSumSingleStatus.parmInventDimCriteria(inventDim); inventTransIdSumSingleStatus.parmInventDimParmCriteria(inventDimParmCriteria); return inventTransIdSumSingleStatus.reservPhysical(); } // Sales order line salesLine = SalesLine::findInventTransId('012431'); inventMovement = InventTrans::findTransId(salesLine.InventTransId).inventMovement(true); // Build inventDim-Record, where the quantity should be reserved inventDim.clear(); inventDim.InventSiteId = "1"; inventDim.InventLocationId = "12"; inventDim.wmsLocationId = "12"; inventDim = InventDim::findOrCreate(inventDim); // Get current physical reserved Quantity oldReservedQty = getReservedQty(); // Set quanity which should be reserved (negative values to reserve, postive value to unreserve) reserveQty = -2; inventUpd_Reservation = InventUpd_Reservation::newInventDim(inventMovement, inventDim, reserveQty, true); inventUpd_Reservation.updateNow(); // Get new reserved quantity newReservedQty = getReservedQty(); // Compare old and new reserved quantity to identify if reservation failed if(oldReservedQty == newReservedQty) { error("Reservation failed."); } } |
|
|
|
|
|
|
The following job creates a picking list line for a production order.