Quantcast
Channel: Microsoft Dynamics AX Forum - Recent Threads
Viewing all articles
Browse latest Browse all 175888

RE: Releasing non-picking list confirmed sales order reservations

$
0
0

Thanks for pointing me in the right direction. I've re-used some of the code in the edit method for that "reservation quantity" field. I wrote a job to un-reserve all of my lines that fit my criteria and it seems to be working fine.

Here's my basic job if anyone wants to pick it apart (hi martin):

static void RemoveSalesLineReservations(Args _args)
{
    SalesLine               salesLine;
    SalesTable              salesTable;
    WMSPickingRoute         pickingRoute;
    InventQty               reservQty;
    InventMovement          movement;
    
    ttsBegin;
    while select forUpdate salesLine
        where salesLine.reservation == ItemReservation::Automatic
    join forupdate salesTable
        where salesTable.salesid == salesLine.SalesId
            && SalesTable.salesstatus == SalesStatus::Backorder
            //&& salesTable.salesid == 'SO-0040339'
    notexists join pickingRoute
        where pickingRoute.transType == InventTransType::Sales
            && pickingRoute.transRefId == salesTable.SalesId
            && (pickingRoute.expeditionStatus == WMSExpeditionStatus::Activated
            || pickingRoute.expeditionStatus == WMSExpeditionStatus::Complete)
    {
        
        salesTable.Reservation = ItemReservation::None;
        
        if(salesTable.validateWrite())
        {
            salesTable.update();
        }
        
        salesLine.reservation = ItemReservation::None;
        salesLine.PdsBatchAttribAutoRes = NoYes::No;
        if(salesLine.validateWrite())
        {
            salesLine.update();
        }
        
        movement    = InventMovement::construct(salesLine);
        reservQty   = (- movement.transIdSum().reserved()) ; //reverse reservation

        if (reservQty)
        {
            InventUpd_Reservation::updateReserveBuffer(salesLine, reservQty);

            // write down activate now on sales line (inventDeliverNow) if reservation is reduced
            if (salesLine.InventDeliverNow > salesLine.reservedPhysical())
            {
                salesLine.InventDeliverNow = salesLine.reservedPhysical();
                salesLine.update();
            }
        }
    }
    ttsCommit;
}



Viewing all articles
Browse latest Browse all 175888

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>