Sunday, June 14, 2015

Receive and ship a transfer order through X++

// Receive and ship a transfer order through X++

private void toCancelTo()
{
    //info(strFmt("%1 -- %2 ",transDate,Transferid));
    Query                   query;
    QueryBuildDataSource    qbds;
    QueryBuildRange         qbrtransId,qbrDate;
    QueryRun                qr;
    ;
    query = new query();
    qbds= query.addDataSource(tableNum(InventTransferTable));
    if(transDate != dateNull())
    {
        qbds.addRange(fieldNum(InventTransferTable,CreatedDateTime)).value(SysQuery::range(dateNull(),transDate));
    }
    //qbds.addRange(fieldNum(SalesTable,CustAccount)).value("R0003");
    if (Transferid != "")
    {
        qbrtransId = qbds.addRange(fieldNum(InventTransferTable,Transferid));
        qbrtransId.value(Transferid);
    }
    qr = new QueryRun(query);
    while(qr.next())
    {
        transferTable = qr.get(tableNum(InventTransferTable));

        ttsBegin;
        while select forupdate transferLine
                where transferLine.Transferid == transferTable.Transferid
        {
            //FUAE-000770
            if (transferLine.QtyRemainShip >= 0.00)
            {
                transferLine.QtyRemainShip = 0.00; //Status shipped
                transferLine.QtyRemainReceive = 0.00; // Status Receive
             
                transferLine.update();
                InventMovement::bufferSetRemainQty(transferLine);
            }

        }
        ttsCommit;
    }
}

No comments:

Post a Comment

Convert Call stack to readable format in D365FO X++

//Input --container _xppCallStack = xSession::xppCallStack();  Public static str POL_formatXppCallStack(container _xppCallStack, int _skipFr...