Thursday, December 5, 2019

Pick the sales line which is unpicked earlier

Hi,

In my earlier post i have explained how to unpick the sales line which is the picking list registration is  already completed.

Here we see how to pick again the unpicked salesline and change status as Picked.

 private void pickSalesLine(SalesId _salesId)
    {
        InventTrans             inventTrans;
        InventTransOrigin       inventTransOrigin;
        WMSOrderTrans           orderTrans;
        InventTransWMS_Pick     inventTransWMS_Pick;
        Query                   query;
        QueryRun                queryRunInvTrans;
        TmpInventTransWMS       tmpInvTransWMS;
        InventDim               inventDimPick;
        InventDim               inventDimfind;
       QueryBuildDataSource    qbdsInventTrans;
        QueryBuildDataSource    qbdsWmsOrderTrans;
        QueryBuildDataSource    qbdsInventTransOrigin;         
         
 query = new Query();

 qbdsInventTrans = query.addDataSource(tableNum(InventTrans));
            qbdsInventTrans.addRange(fieldNum(InventTrans,StatusReceipt)).value(SysQuery::value(StatusReceipt::None));
            qbdsInventTrans.addRange(fieldNum(InventTrans,StatusIssue)).value(SysQuery::value(StatusIssue::OnOrder));
            qbdsInventTrans.addRange(fieldNum(InventTrans,StatusIssue)).value(SysQuery::value(StatusIssue::ReservPhysical));
qbdsInventTrans.addRange(fieldNum(InventTrans,TransChildType)).value(SysQuery::value(InventTransChildType::None));
        qbdsInventTrans.addRange(fieldNum(InventTrans,TransChildRefId)).value(SysQuery::value(strMin()));

            qbdsInventTransOrigin = qbdsInventTrans.addDataSource(tableNum(InventTransOrigin));
            qbdsInventTransOrigin.addLink(fieldNum(InventTransOrigin, RecId),fieldNum(InventTrans, InventTransOrigin));
            qbdsInventTransOrigin.joinMode(JoinMode::InnerJoin);
            qbdsWmsOrderTrans = qbdsInventTransOrigin.addDataSource(tableNum(WMSOrderTrans);
qbdsWmsOrderTrans .addLink(fieldNum(InventTransOrigin,InventTransId),fieldnum(WMSOrderTrans,InventTransId));
qbdsWmsOrderTrans .joinMode(JoinMode::InnerJoin);
qbdsWmsOrderTrans.addRange(fieldnum(WMSOrderTrans,TransRefId)).value(queryValue(_salesId));

            delete_from tmpInvTransWMS;
            inventTransWMS_Pick = InventTransWMS_Pick::newStandard(tmpInvTransWMS,query);
            queryRunInvTrans = new QueryRun(query);
            queryRunInvTrans.next();
            while(queryRunInvTrans.next())
            {
            inventTrans = queryRunInvTrans.get(tableNum(InventTrans));
            inventTransOrigin = queryRunInvTrans.get(tableNum(InventTransOrigin));
            inventDimPick = inventTrans.inventDim();
          //  inventDimPick.inventBatchId = "B001";
            inventDimPick = InventDim::findOrCreate(inventDimPick);
            tmpInvTransWMS.clear();
            tmpInvTransWMS.initFromInventTrans(inventTrans);
            tmpInvTransWMS.initFromInventTransOrigin(inventTransOrigin);
            tmpInvTransWMS.initFromInventDim(inventDimPick);
           // tmpInvTransWMS.InventQty = 5;
            inventTransWMS_Pick.writeTmpInventTransWMS(tmpInvTransWMS);
            inventTransWMS_Pick.updateInvent();
           }
         
        }
    }

No comments:

Post a Comment