Monday, June 24, 2013

Split Purchase order lines

Sometime we need to split purchase order line into multiple lines with Quantity = 1, here is a piece of code through which you can split purchase order line into multiple lines. You can easily alter the below code based on your Quantity factor.

static void SplitPurchLine(Args _args)
{
    PurchQty    qty;
    PurchTable  purchTable;
    PurchLine   purchLine;
    
    purchTable = PurchTable::find("PO-0001");
    
    while select forUpdate purchLine
        where  purchLine.PurchId == purchTable.PurchId && purchLine.PurchQty > 1
    {
        qty = purchLine.PurchQty;

        while (qty > 1)
        {
            PLPurchLineSplit::update(purchLine, 1);
            qty -= 1;

        }
    }
}

Post a Comment