{
{
Integer lastRec = 0;
SalesId oldSalesId;
inventTrans inventTrans;
SalesFormLetter salesFormLetter;
inventTransOrigin inventTransOrigin;
TradeOrderLineRegister tradeOrderlineRegister;
SalesReturnOrderLineRegister salesReturnOrderLineRegister;
InventTransWMS_Register inventTransWMS_register;
TmpInventTransWMS TmpInventTransWMS;
SalesLine salesLineReg;
ReturnDispositionCode returnDispositionCode;
//SON_IPB49_InventStkTransHeader headerTable,headerTableLoc;
Description255 errorMsg;
select firstOnly * from returnDispositionCode
where returnDispositionCode.DispositionAction == DispositionAction::Credit;
where salesLineReg.SalesId == "xxx";/*salesLineReg.SalesId
&& _salestable.SalesType == SalesType::ReturnItem*/
args.record(salesLineReg);
tradeOrderLineRegister.parmArgs(args);
tradeOrderLineRegister.init();
salesReturnOrderLineRegister = tradeOrderLineRegister;
salesReturnOrderLineRegister.runPreSuper();
salesLineReg.ReturnDispositionCodeId = returnDispositionCode.DispositionCodeId ; //returnDispositionCode.DispositionCodeId;
salesLineReg.update();
join RecId,InventTransId from inventTransOrigin
where inventTransOrigin.InventTransId == salesLineReg.InventTransId
&& inventTrans.InventTransOrigin == inventTransOrigin.RecId;
// inventDim = inventTranslocal.inventDim();
InventDim inventDim = inventTrans.inventDim();
inventDim.inventBatchId = "BatchNew";
inventDim.InventLocationId = "xxx";
inventDim.wMSLocationId = "NA";
inventDim.InventSiteId = "xxx";
inventDim.InventStatusId = "AL";
inventDim = InventDim::findOrCreate(inventDim);
inventTrans.InventDimId = inventDim.inventDimId;
tmpInventTransWMS.clear();
tmpInventTransWMS.initFromInventTrans(inventTrans);
tmpInventTransWMS.InventDimId = inventTrans.InventDimId;
tmpInventTransWMS.InventQty = 1;
tmpInventTransWMS.insert();
inventTrans.selectForUpdate(true);
inventDim.selectForUpdate(true);
salesLineReg.selectForUpdate(true);
inventTransWMS_register.writeTmpInventTransWMS(tmpInventTransWMS,
inventTrans,
inventDim);
inventTransWMS_register.updateInvent(salesLineReg);
// inventTransWMS_register.updateInvent(inventTrans);
ttscommit;
Info("completed");
}
Site=SYD,Warehouse=GS1,Location=NA,Inventory status=AL,Batch number=BatchNew
Cannot edit a record in Batches (InventBatch). The record has never been selected.