How to Re-Order Erp.BO.OrderAllocListDataSet.OrderAllocDataTable by Need By Date

Hello, I was wondering if anybody had any ideas on how to reoder a Epicor specific DataTable by a column, namely Erp.BO.OrderAllocListDataSet.OrderAllocDataTable by "NeedByDate’. I have tried using the sort method on Default view of a table and then casting the .ToTable() method to a OrderAllocDataTable, but get a runtime error. Also, you cannot set the .ToTable() method to a OrderAllocDataTable directly, because the value in the OrderAllocDataSet is read only.

I am assuming I could loop through, compare to the Default View values and then import the row into a new OrderAllocDataTable, but that would be getting costly and messy. Any ideas?

Thanks

**Below does not work, as you get the following error:
Error CS0200 Property or indexer ‘OrderAllocListDataSet.OrderAllocList’ cannot be assigned to – it is read only

OrderAllocDS.OrderAllocList.DefaultView.Sort = “NeedByDate”;
DataTable SortedTable = OrderAllocDS.OrderAllocList.DefaultView.ToTable();
Erp.BO.OrderAllocListDataSet SortedDS = new Erp.BO.OrderAllocListDataSet();
SortedDS.OrderAllocList = (Erp.BO.OrderAllocListDataSet.OrderAllocListDataTable) OrderAllocDS.OrderAllocList.DefaultView.ToTable();

DataTable orderAllocList = OrderAllocAdapter.OrderAllocList.OrderAllocList.Copy();

?

I think the first orderAllocList is a DataSet, and the second is the DataTable? Or have you already got the DataSet first?

Hey Daryl,

The variable OrderAllocDS is a DataSet already. That makes OrderAllocDS.OrderAllocList the OrderAllocListDataTable, which I am trying to orgranize by NeedByDate. The issue is I cannot assign it to a normal DataTable as the downstream process I am trying to send it to requires it to be a OrderAllocListDataTable. Or at least that is the assumption I am making, as when I sent it to a DataTable, and import each row of that DataTable into a OrderAllocListDataTable, the function I was trying to perform did not execute correctly. I am trying to AutoReserve Orders.

Thanks for your help on this!

Sorry, I think I’m probably missing some of what you’re trying to do! I had thought that the Epicor DataTables were still just DataTables, and the EpiMagic happens in the higher layers.

Below is the nearest code I’ve used to what you’re saying, ie copying one dataset to another, which had to be done row by row and for every table in the dataset:

Ice.BO.DynamicQueryDataSet dsQDesign = adptr.QueryDesignData;
DataRow targetRow;
foreach (DataTable table in ds.Tables)
{
	foreach (DataRow sourceRow in dsQDesign.Tables[table.ToString()].Rows)
	{
		targetRow = table.NewRow();
		targetRow.ItemArray = sourceRow.ItemArray;
		table.Rows.Add(targetRow);
	}
}

I suspect the real key may be in the downstream part, though. I’m not sure I have all the knowledge you need, so maybe someone else can help better.

Thanks for the code, Daryl!

I do not know for sure about the DataTable scenario, it just seems Auto Reserving with DataRows imported from a normal DataTable loses some piece of EpiMagic, as it won’t properly reserve.

It may be worth posting some of the part where you’re actually having the problem? One things that raises some alarm bells with me is the use of the List dataset, since it doesn’t usually have the right data in it to do much except reading out the existence of things. But either way I suspect there’s something going wrong somewhere else.

Thanks for the follow up Daryl. I will respond with a more in-depth description of what I am trying to accomplish and where the issue occurs in the coming days.

I am attempting to AutoReserve orders. Using Erp.Contracts.BO.OrderAlloc, I call GetListOfOrders(), which returns the OrderAllocListDataSet. This OrderAllocListDataSet gets passed to the OrderAllocationGetRows() method, returning the OrderAllocDataSet. This OrderAllocDataSet gets turned into a SlimOrderAllocDataSet and then gets AutoReserved.

The issue that is occurring is the OrderAllocDataSet, and all subsequent data, is orderd by ShipByDate Date. Trying to use traditional methods to reorder the DataTable inside the DataSet (using .sort on the DataView, using .select(), etc) allow the DataTable in the DataSet to be reordered as a generic DataTable, but not as an OrderAllocDataTable. This does not allow it to be reserved properly when calling AutoReserve(). It doesn’t throw an error, it just doesn’t reserve.

So the holy grail would be to find a way to reorder the OrderAllocDataTable (That lives inside the OrderAllocDataSet) without converting it to a DataTable.

Thank you for your help regarding this.

Erp.Proxy.BO.OrderAllocImpl oa = Ice.Lib.Framework.WCFServiceSupport.CreateImpl<Erp.Proxy.BO.OrderAllocImpl>(session, Epicor.ServiceModel.Channels.ImplBase<Erp.Contracts.OrderAllocSvcContract>.UriPath);

            //Setting Parameters for intial GetListOfOrders. This returns the orders to be reserved, as a OrderAllocListDataSet
string waveWhereClause = String.Empty;
string orderHedWhereClause = "OrderHed.OrderHeld = false";
string orderDtlWhereClause = String.Empty;
string orderRelWhereClause = "OrderRel.ReqDate <= '" + DateTime.Now.AddDays(21).ToString("MM/dd/yyyy") + "'";
string customerWhereClause = String.Empty;
string partAllocWhereClause = "NoFilter,NoFilter,NoFilter,NoFilter";
string countryWhereClause = String.Empty;
string shipToWhereClause = String.Empty;
string creditHoldClause = "NoFilter";
string i_SortByOrder = String.Empty;
string i_SortByWarehouse = String.Empty;
string i_SortByAllocation = String.Empty;

//This determines how many order records are brought back. 0 brings them all back
int pageSize = 10;
int absolutePage = 0;
bool morePages = false;
string NO_Company = String.Empty;

//Getting orders to reserve
Erp.BO.OrderAllocListDataSet OrderAllocDS = oa.GetListOfOrders(waveWhereClause,
                                orderHedWhereClause, orderDtlWhereClause, orderRelWhereClause, customerWhereClause, partAllocWhereClause,
                                countryWhereClause, shipToWhereClause, creditHoldClause, i_SortByOrder, i_SortByWarehouse, i_SortByAllocation, pageSize,
                                absolutePage, out morePages, NO_Company);

 Erp.BO.OrderAllocDataSet oaDataSet = oa.OrderAllocationGetRows(OrderAllocDS, 0);

//Some massaging of data occurs here, to get the OrderAllocDataSet to a Slim OrderAllocDataSet

oa.CheckDates(SlimOrderAllocSet, out cMessageText);
oa.AutoReserve(SlimOrderAllocSet, cIPWhseList, CWhseType, out cMessageText);

Hi

Why don’t you use the i_SortByOrder parameter
e.g.
var i_SortByOrder = “OrderHed.ReservePriorityCode , OrderRel.OrderNum, OrderRel.OrderLine, OrderRel.OrderrelNum”;

e10OrderAllocListDataSet = _orderAllocImpl.GetListOfOrders(
… i_SortByOrder, i_SortByWarehouse, i_SortByAllocation, 0, 0, out morePages, “”);

Thank you Erwin, that was the ticket. I set i_SortByOrder = “OrderRel.NeedByDate” and voila! Did not even have to mess with the DataSets or Tables.

Thank you Daryl for all your help on this, also.

how are you reserving your sales order? retrieving all potential orders and running a mass reservation or selectively by sales order?

Running a mass reservation by plant and ship by/need by. We currently have an employee who does this full time.

same as us, we run on a schedule any sales order that is due in the next 30 days, optionally select a sales order via a dashboard