Reverse PO in ax 2012

  A simple way to reverse Po in ax 2012



void clicked()

{

    PurchLine purchLineloc ;

    Purchtable purchtableloc;

    super();

    select PurchId from purchline

        where purchline.ItemId == RentalLinesIntake.Rentalreference; // itemid

    purchLineloc = PurchLine::find(purchline.purchid);



    if (purchLineloc)

    {

        purchLineloc.selectForUpdate(true);

        ttsBegin;

        purchLineloc.RemainInventPhysical  = 0;



        purchLineloc.RemainPurchPhysical   = 0;


        purchLineloc.PurchStatus           = PurchStatus::Canceled;


        purchLineloc.update();

        ttsCommit;


        InventMovement::bufferSetRemainQty(purchLineloc);


        purchtableloc = PurchTable::find(purchLineloc.PurchId,true);

        purchtableloc.delete();

        info("done");


    }



}

No comments:

Post a Comment