How to Cancel a Sales Order Using X++


while (salesTable)
   {
       ordersToUpdate.addEnd(salesTable.RecId);
       salesTable = selection.getNext();
   }
   SalesUpdateRemain::cancelRemainderOnManySalesOrders(ordersToUpdate.pack());
Or SalesUpdateRemain::cancelRemainderOnOpenSalesLines(salesTable) for one order