Thursday, December 5, 2019

Unpick sales line once picking list registration is completed

sometimes you need to unpick the salesline quanity once the sales order picking list generated.

There is two options available in standard from front end.

First option
1. Select the Sales order -> Picking list registrations -> Function -> Cancel picking route.
it will cancel the particular picking list details for that picking route id

Second option
2. Select the sales order -> select the Sales line -> Update line -> Pick
      a) select the sales line in the pop up form
      b) Confirm the sales line status is "picked"
      b) Click add picking line
      c) the line will be added in the bottom grid
      d) update the quantity with negative value
      e) The updated number of quantity will be changed as On order status

Please find below code to unpick all sales lines for the sales order irrespective of Picking list.

private void unPickSalesLines(SalesId _salesId)
    {
        InventTrans                            invTrans;
        InventTransWMS_Pick         inventTransWMS_Pick;
        Query                                     queryInvetTrans;
        QueryRun                              queryRunInvTrans;
        TmpInventTransWMS          tmpInvTransWMS;
        QueryBuildDataSource         qbdsInventTrans;
        QueryBuildDataSource         qbdsWmsOrderTrans;
        QueryBuildDataSource         qbdsInventTransOrigin;
        InventDimParm                     inventDimParmAllTransactions;

        // pick > add picking line
        queryInvetTrans = new Query();
        qbdsInventTrans = queryInvetTrans.addDataSource(tableNum(InventTrans));
        qbdsInventTrans.clearDynalinks();
        qbdsInventTrans.clearRanges();

  qbdsInventTrans.addRange(fieldNum(InventTrans,StatusReceipt)).value(SysQuery::value(StatusReceipt::None));
        qbdsInventTrans.addRange(fieldNum(InventTrans,StatusIssue)).value(SysQuery::value(StatusIssue::Picked));
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(InventTrans, InventTransOrigin),fieldNum(InventTransOrigin, RecId));
        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, inventTransRefId)).value(SysQuery::value(_salesId));
        qbdsWmsOrderTrans.addRange(fieldNum(WMSOrderTrans, expeditionStatus)).value(SysQuery::value(WMSExpeditionStatus::Complete));

        inventDimParmAllTransactions.clear();

        inventTransWMS_Pick = InventTransWMS_Pick::newStandard(tmpInvTransWMS,queryInvetTrans);

        queryRunInvTrans = new QueryRun(queryInvetTrans);

        while(queryRunInvTrans.next())
        {
            invTrans = queryRunInvTrans.get(tableNum(InventTrans));
            inventTransWMS_Pick.createFromInventTrans(invTrans);
        }
       
        inventTransWMS_Pick.updateInvent();
 }

No comments:

Post a Comment