Unallocate Sales Order

Hi .

I need to unallocate a determinate sales order (E.g OrderNum = 31 ) ; I have found a little example and I modified this to my issue ; I think I have to use the methods GetListOfOrders , OrderAllocationGetRows and finally UnallocateAndUnreserve ; but when i run my code , in the “GetListOfOrders” method I get the message “Specified argument was out of the range of valid values.”
The original code in the example indicate that the method requiere 16 arguments , but If i try to put it as the exple says i get the message “No overload for method ‘GetListOfOrders’ takes 16 arguments” ; This is clear for me because in the object explorer the method require only two arguments.

Im really apreciate any help.

My code:

//Unallocate Sales Order
System.Data.DataSet OrderAllocListDataSet;
Erp.Tablesets.OrderAllocTableset OrderAllocDataSet;
bool morePages = false;
string outMessage = string.Empty;
OrderAllocAdapter AllAdp = new OrderAllocAdapter(UD24Form);
AllAdp.BOConnect();
SearchOptions options = new SearchOptions(SearchMode.AutoSearch);
options.PreLoadSearchFilter = “OrderNum = 31”;// My Idea
//OrderAllocListDataSet = AllAdp.GetListOfOrders(options, out morePages);// My Idea
OrderAllocListDataSet = AllAdp.GetListOfOrders("",String.Format(“OrderNum = {0}”,31),"","","",“NoFilter,NoFilter,NoFilter,NoFilter”,"","","","","","",0,0,out morePages,"");// What the example says
//OrderAllocDataSet = AllAdp.OrderAllocationGetRows(OrderAllocListDataSet,0);
// AllAdp.UnallocateAndUnreserve(ref OrderAllocDataSet, out outMessage);
AllAdp.Dispose();

I know this is pretty old but I’ve just been through a similar process of trying to work out how to unallocate an order in code.

In the end I I skipped the GetListOfOrders method calls and just created a BAQ to list the allocated lines I was interested in.

I then looped through this list and manually added the lines to the adapter’s dataset:

			var newRow = this.orderAllocAdapter.OrderAllocData.OrderAlloc.NewRow();
			newRow.BeginEdit();
			
			newRow["Company"] = allocDetail["PartAlloc_Company"];
			newRow["OrderNum"] = allocDetail["PartAlloc_OrderNum"];
			newRow["OrderLine"] = allocDetail["PartAlloc_OrderLine"];
			newRow["OrderRelNum"] = allocDetail["PartAlloc_OrderRelNum"];
			newRow["PartNum"] = allocDetail["PartAlloc_PartNum"];
			newRow["Plant"] = allocDetail["Warehse_Plant"];
			newRow["SysRowID"] = Guid.NewGuid();
			newRow["OrderNumLineRel"] = orderNumLineRel;
			newRow["DemandType"] = allocDetail["PartAlloc_DemandType"];
			
			newRow["DemandKey1"] = allocDetail["PartAlloc_OrderNum"];
			newRow["DemandKey2"] = allocDetail["PartAlloc_OrderLine"];
			newRow["DemandKey3"] = allocDetail["PartAlloc_OrderRelNum"];
			newRow["LineType"] = "PART";

			newRow["AllocatedQty"] = allocDetail["Calculated_AllocQty"];
			newRow["PickingQty"] = allocDetail["Calculated_PickiQty"];
			newRow["PickedQty"] = allocDetail["Calculated_PickeQty"];
			newRow["ReservedQty"] = allocDetail["Calculated_ResvQty"];

			newRow["FulfillmentSeq"] = fulfillmentSeq++;
			newRow["DisplaySeq"] = newRow["FulfillmentSeq"];

			newRow["NeedsUpdate"] = true;
			newRow["SelectedForAction"] = true;
			newRow["EnableSelectForPicking"] = false;

			newRow.EndEdit();
			this.orderAllocAdapter.OrderAllocData.OrderAlloc.Rows.Add(newRow);

I then called some tidy up methods (I can’t tell you if I needed to call these but I couldn’t be bothered to pull them out and retest)

		orderAllocAdapter.OrderAllocationGetRows();
		orderAllocAdapter.Recalculate();

Before finishing off

this.orderAllocAdapter.UnallocateAndUnreserve(out message);
1 Like

This is genius! I just need to set the RowMod to “U” and it worked great! Thanks for this man!

I’m trying to use the OrderAlloc adapter to make Unallocate/Unreserve transactions on a custom screen that grabs PartAllocations. Is there a way to query the OrderAlloc dataset to get the exact record I want to Unallocate/Unreserve. The trace really doesn’t show much for these types of transactions in FWB.

Thank you.