Cancel Post packing slip from all Shipments in D365 F&O through X++
Hi Viewers,
To Cancel Post packing slip for Shipments. we first have to cancel the Packing slip, reverse the shipment, and then reopen the container.
To Cancel Post packing slip:
WHSLoadTableCustPackingSlipJour loadCustJour;
CustPackingSlipJour custJour;
WHSLoadTable loadTable;
CustPackingSlipJour custJour;
WHSLoadTable loadTable;
loadTable = whsshipmenttable::find(ShipmentID).whsLoadTable();
while select custJour
where custJour.Qty
exists join loadCustJour
where loadCustJour.WHSLoadTableLoadId == loadTable.LoadId
&& loadCustJour.WHSLoadTableDataAreaId == loadTable.DataAreaId
&& loadCustJour.CustPackingSlipJourRecId == custJour.RecId
{
Args args = new Args();
args.record(custJour);
args.parmEnum(enum2int(DocumentStatus::PackingSlip));
new MenuFunction(menuItemActionStr(SalesFormLetter_PackingSlipCancel), MenuItemType::Action).run(args);
}
To Reverse shipment:
WHSShipmentTable shipmentTable;
WHSLoadLine loadlines, loadlines2;
shipmentTable = WHSShipmentTable::find(ShipmentID);
select loadlines
where loadlines.ShipmentId == shipmentTable.ShipmentId
&& loadlines.InventTransType == InventTransType::Sales;
WHSReverseShipConfirm reverseShipConfirm = WHSReverseShipConfirm::newFromLoadTable(loadlines.whsLoadTable());
reverseShipConfirm.reverseShipConfirm();
To reopen containers:
WHSContainerTable containerTable;
WHSCloseContainerProfile closeContainerProfile;
WHSShipmentTable shipmentTable;
containerTable = WHSContainerTable::findByContainerId(ContainerId);
closeContainerProfile = WHSCloseContainerProfile::find(containerTable.CloseContainerProfileId);
shipmentTable = WHSShipmentTable::find(containerTable.ShipmentId);
WHSContainerTable::reOpenContainer(
shipmentTable.ShipmentId,
containerTable.ContainerId);
WHSCloseContainerProfile closeContainerProfile;
WHSShipmentTable shipmentTable;
containerTable = WHSContainerTable::findByContainerId(ContainerId);
closeContainerProfile = WHSCloseContainerProfile::find(containerTable.CloseContainerProfileId);
shipmentTable = WHSShipmentTable::find(containerTable.ShipmentId);
WHSContainerTable::reOpenContainer(
shipmentTable.ShipmentId,
containerTable.ContainerId);
Comments
Post a Comment