Step 1

Create WMSShipment record.
        WMSShipment                     wmsShipment;
    SalesTable                      salesTableLocal;
    salesTableLocal = SalesTable::find(‘SO-101328’);
    wmsShipment.clear();
    wmsShipment.initTypeOrderPick();
    wmsShipment.insert();

Step 2

Create WMSPickingRoute record.
    WMSPickingRoute                 wmsPickingRoute;
    wmsPickingRoute.clear();
    wmsPickingRoute.initTypeOrderPick(wmsShipment, WMSExpeditionStatus::Activated,                  WMSPickRequestTable::construct(salesTableLocal), ”, true);
    wmsPickingRoute.ActivationDateTime = DateTimeUtil::utcNow();
    wmsPickingRoute.insert();

Step 3

Create WMSPickingRouteLink record.
    WMSPickingRouteLink          wmsPickingRouteLink;
    wmsPickingRouteLink.initFromSalesTable(salesTableLocal);
    wmsPickingRouteLink.initFromWMSPickingRoute(wmsPickingRoute);
    wmsPickingRouteLink.insert();

Step 4

Create SalesPickingList line using WMSOrderCreate class.
    SalesLine                       salesLineLocal;
    InventMovement                  inventMovement;
    WMSOrder                        wmsOrder;
    WMSOrderCreate                  orderCreate;
    WMSOrderTrans                   wmsOrderTrans;

// Creating records for each salesline
while select salesLineLocal
        where salesLineLocal.SalesId == salesTableLocal.SalesId
    {
        // Inventory Movement object is required to create new           SalesPickingList lines
        inventMovement = InventMovement::construct(salesLineLocal);
        orderCreate = WMSOrderCreate::newMovement(inventMovement, -cancelQty);
        orderCreate.parmMustBeWMSOrderControlled(true);
        orderCreate.parmQty(cancelQty);
        orderCreate.parmRecalculateMaxQtyForValidation(false);
        orderCreate.parmMaxCWQty(cancelQty);
        orderCreate.parmMaxQty(cancelQty);
        orderCreate.run();
        wmsOrder = orderCreate.parmWMSOrder();
        wmsOrder.updateShipment(wmsShipment, cancelQty, wmsPickingRoute.PickingRouteID, false);

        // Updating status to activated 
        while select forupdate wmsOrderTrans
            where wmsOrderTrans.inventTransId ==  salesLineLocal.inventTransId
               && wmsOrderTrans.expeditionStatus == WMSExpeditionStatus::Registered
        {
            ttsBegin;
            wmsOrderTrans.expeditionStatus = WMSExpeditionStatus::Activated;
            wmsOrderTrans.update();
            ttsCommit;
        }
    }