Pick from sales order and post packing slip

SalesTable salesTable = SalesTable::find("SO100053");
SalesLine salesLine;

Query inventTransQuery;
QueryBuildDataSource inventTransQbds;
InventTrans inventTrans;
InventTransOrigin inventTransOrigin;

TmpInventTransWMS tmpInventTransWMS;
InventTransWMS_Pick inventTransWMS_Pick;

while select salesLine
     where salesLine.SalesId == salesTable.SalesId
{
      inventTransQuery                = new Query();
      inventTransQbds                  = inventTransQuery.addDataSource(tableNum(InventTrans));
      inventTrans                           = InventTrans::findTransId(_InventtransId);
      inventTransOrigin               = InventTransorigin::findByInventTransId(salesLine.InventTransId);
      inventTransQbds.addRange(fieldNum(InventTrans,RecId)).value(int642str(salesLine.InventTransId));

      delete_from tmpInventTransWMS;
      tmpInventTransWMS.clear();
      inventTransWMS_Pick             = InventTransWMS_Pick::newStandard(tmpInventTransWMS,inventTransQuery);
      tmpInventTransWMS.initFromInventTrans(InventTrans);
      tmpInventTransWMS.initFromInventTransOrigin(InventTransOrigin);
      tmpInventTransWMS.InventQty     = 3;
      //tmpInventTransWMS.InventDimId   = _InventDimId;
      inventTransWMS_Pick.writeTmpInventTransWMS(tmpInventTransWMS);
      inventTransWMS_Pick.updateInvent();
    
      SalesFormLetter                 = SalesFormLetter::construct(DocumentStatus::PackingSlip);
      SalesTable                      = SalesTable::Find(salesLine.salesId);
      SalesFormLetter.update(SalesTable,systemDateGet(), SalesUpdate::PickingList, AccountOrder::None, false, false);    
}

 

Leave a Comment