Solved

Please Help With OrderAlloc Adapter

  • 23 June 2023
  • 1 reply
  • 86 views

Userlevel 2

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;

        Ice.Lib.Searches.SearchOptions opt = new Ice.Lib.Searches.SearchOptions(Ice.Lib.Searches.SearchMode.AutoSearch);

        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.OrderAlloc.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

icon

Best answer by MontyWilson 26 June 2023, 17:08

View original

1 reply

Userlevel 2

We ended up not being able to look up any usable data in the PartAlloc table (OrderAlloc data set) through the Business Object, so we went with the approach below, and it works.  We just moved the database record read into an Epicor Function.  Thanks!

 

    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

Reply