OrderAlloc adapter - UnallocateAndUnreserve metho

Good morning,

I built a screen that when it processes, it needs to Unallocate and Unreserve just as Fulfillment Workbench does. User selects a row, clicks a button, and it unallocates and unreserves.

The OrderAllocAdapter is strange, but when I follow the trace, it looks like I need to get the list dataset (which I have been able to do just fine), convert it to a DataSet and then run OrdAllocAdapter.UnallocateAndUnreserve().

I am struggling to convert it to a dataset. Below is my code (built largely from the help of this awesome forum!) and the last line is where I am trying to get a dataset from my listdataset. The compiler says the method OrderAllocationGetRows() doesn’t take 2 arguments, but the trace shows this is exactly what it’s doing. I’m hoping someone can fill in this gap for me and others when they hit this issue.

if ((bool)ugr.Cells["Select"].Value == true)
{
	Ice.Core.Session session = (Ice.Core.Session)UD01Form.Session;
	Erp.Adapters.OrderAllocAdapter OAAdapter = new Erp.Adapters.OrderAllocAdapter(oTrans);
	Erp.BO.OrderAllocListDataSet OAlds = new Erp.BO.OrderAllocListDataSet();
	Erp.BO.OrderAllocDataSet OAds = new Erp.BO.OrderAllocDataSet();
	string vOrderNum = ugr.Cells["OrderRel_OrderNum"].Value.ToString();
	string vPartNum = ugr.Cells["OrderDtl_PartNum"].Value.ToString();
	string vOrderLine = ugr.Cells["OrderRel_OrderLine"].Value.ToString();
	string message = string.Empty;
	bool morePages;
	Ice.Lib.Searches.SearchOptions opts = new SearchOptions(SearchMode.AutoSearch);
	OAAdapter.DefaultSearchType = Erp.Adapters.OrderAllocAdapter.SearchType.SO;
	OAAdapter.SearchForm = new Erp.UI.Searches.OrderSearchForm();
	opts.SearchMethod = new AlternateSearchMethod(OAAdapter.GetListOfOrders);
	opts.SelectMode = SelectMode.MultiSelect;
	string _filter = "OrderNum = " + vOrderNum + " AND OrderLine = " + vOrderLine;
	opts.PreLoadSearchFilter = _filter;
		
	OAAdapter.InvokeSearch(opts);
    OAlds = (OrderAllocListDataSet)OAAdapter.GetListOfOrders(opts, out morePages);

	OAds = OAAdapter.OrderAllocationGetRows(OAlds,0);  //<-- Results in "No overload for method 'OrderAllocationGetRows' takes 2 arguments....
}

The reason I believe I need to convert it into a ds is that I don’t believe I can manipulate records using the ListDataSet. When I try, the compiler says the fields do not exist.

Thank you!
Jeremy

1 Like

To throw it out there: couldn’t I just use the records I get back from the ListDataSet to hit the PartAlloc table and delete/manipulate the records there just as UnallocateAndUnreserve() does?

I was looking to do allocation for transfer order shipments and was thinking along the same lines as you are.

Here is Jose saying he did this via tracing fulfillment workbench.

He said, “I just did this not for transfer orders, and its a bit of a bear.”

Thank you for the reply. I really think I can do it if I can just get an OrderAllocDataSet. The problem is, none of the methods available return an OrderAllocDataSet. I’m using the same exact methods others have used to get the dataset, such as OrderAllocAdapter.OrderAllocationGetRows(), but it doesn’t accept any arguments, and (which is my personal favorite) it returns a void.

I’m thinking the adapter has changed in Kinetic (I’m on 2022.1.1), and there’s no documentation on how to use the new adapter. I’m beginning to think I need a workaround and it saddens me.

@Chan213419, did you ever get this to work? I figured out a “fun” solution:

// SNIP
	OAlds = (OrderAllocListDataSet)OAAdapter.GetListOfOrders(opts, out morePages);
// NEW CODE
	ArrayList allocKeys = new ArrayList();
	foreach (DataRow row in OAlds.OrderAllocList.Rows)
	{
		allocKeys.Add(row["SysRowID"]);
	}
	opts.SelectedKeys = allocKeys;
	OAAdapter.DoGetListFromSelectedKeys(opts, out morePages);

This will fill the OrderAllocListDataSet inside of the OAAdapter.

I’m having trouble finding any documentation or postings of OrderAllocData, and what exactly is supposed to be contained within the search results. I’m looking in the REST v2 API help (Swagger) and I don’t see anything in there. I’m in a classic UI customization and all I really need to know is, if a PartAlloc record exists that matches an Order/Line/Release, what the picking quantity in that record is.

I’ve tried OrderAlloc.Count.Rows, PartAlloc.Count.Rows, and OrderAlloc.Rows and PartAlloc.Rows without the Count and nothing seems to give me anything but zero.

My attempt at a Click event handler is below; grateful for any help.

Thanks,
…Monty.


	private void btnShipPicking_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **

		int intOrderNum;
		Erp.Adapters.OrderAllocAdapter adpOrderAlloc = new Erp.Adapters.OrderAllocAdapter(oTrans);
		string strSearch;
		adpOrderAlloc.DefaultSearchType = Erp.Adapters.OrderAllocAdapter.SearchType.SO;

		Ice.Lib.Searches.SearchOptions opt = new Ice.Lib.Searches.SearchOptions(Ice.Lib.Searches.SearchMode.AutoSearch);
		opt.SearchMethod = new AlternateSearchMethod(adpOrderAlloc.GetListOfOrders);
		opt.SelectMode = SelectMode.MultiSelect;
        opt.DataSetMode = Ice.Lib.Searches.DataSetMode.RowsDataSet;
		adpOrderAlloc.BOConnect();

        // move down to where we have O/L/R 
	 // get pack number

	 if (edvShipDtl.HasRow) 
	 {
		string strPackNum = edvShipDtl.dataView[0]["PackNum"].ToString();
        try
        {
            foreach (DataRowView rowView in edvShipDtl.dataView)
            {
                DataRow row = rowView.Row;
                row.BeginEdit();
                row["DisplayInvQty"] = 0; // start each pack line's qty at zero
										  // then look up picking qty by O/L/R in PartAlloc if it's there
//				strSearch  = "Company = '" + ((Ice.Core.Session)oTrans.Session).CompanyID 
//					+ "' AND DemandType = 'Order" 
//					+ "' AND OrderNum = '" + row["OrderNum"].ToString() 
//					+ "' AND OrderLine = '" + row["OrderLine"].ToString() 
//					+ "' AND OrderRelNum = '" + row["OrderRelNum"].ToString() + "'";
				strSearch  = "OrderNum = '" + row["OrderNum"].ToString() + "'" ; // temp simplification for testing

				opt.PreLoadSearchFilter = strSearch;
				adpOrderAlloc.ClearData();
                adpOrderAlloc.InvokeSearch(opt);
		MessageBox.Show("search string " + strSearch + " and rows = " + 
		adpOrderAlloc.OrderAllocData.OrderAlloc.Count.ToString());
		
				if (adpOrderAlloc.OrderAllocData.PartAlloc.Rows.Count > 0) // found matching row(s)?
				{
					for (int i = 0; i < adpOrderAlloc.OrderAllocData.OrderAlloc.Rows.Count; i++) 
					{ // should be only one matching row
						row["DisplayInvQty"] = adpOrderAlloc.OrderAllocData.OrderAlloc.Rows[i]["PickingQty"];
					} // end for (each matching order alloc row, should be only one)
		row["DisplayInvQty"] = 1; // temp just to signal us when we finally get search results
                 } // end if matching OrderAlloc rows found

                row.EndEdit();
            } // end for each row in data row view
            
        } // end try
        catch
        {
			MessageBox.Show("search error");
        }
     } // end if row exists in edv
	 oTrans.Update();
	} // end click event handler

We ended up at a brick wall trying to get any PartAlloc table data out of business object calls. We moved the DB access into an Epicor Function and were able to get it to work that way. Thanks Everyone! The event handler code is below.

Best,
…Monty.

	private void btnShipPicking_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **

	 if (edvShipDtl.HasRow) 
	 {
	  using (var restClient = new RestClientBuilder().UseSession(this.oTrans.CoreSession).Build())
	  { 
        foreach (DataRowView rowView in edvShipDtl.dataView) // for each row in pack line data view
        {
            DataRow row = rowView.Row;
            row.BeginEdit();


                try
            	{
   				 var parameters = new RestContent(  // Declare InputParameters structure
						new { OrderNum = row["OrderNum"], OrderLine = row["OrderLine"], OrderRelNum = row["OrderRelNum"]});
					var response = restClient.Function.Post(
					     "Packer", // Library
					     "OrderPickingQty", // MethodName
					     parameters, 
					     published: true);
					var result = response.GetAnonymousResult(
					     // Declare OutputParameters structure
					     new { PickingQty = 0.0M, } // decimal return parameters' placeholders must be a value that can't be int
					     );
					if (result != null) // function returns zero if part alloc record doesn't exist
						row["DisplayInvQty"] = result.PickingQty;

				} // end try
	            catch (Exception ex)
	            {
	                ExceptionBox.Show(ex);
	            } // end catch exception


            row.EndEdit();
        } // end for each row in data row view
      } // end using REST client
      
     } // end if row exists in edv
	 oTrans.Update();
	} // end click event handler
1 Like