Server Side Exception: Error Accessing the Database

,

I am trying to do an inventory adjustment via a bpm from a UD table. I am getting a Server Side Error pop up and I can’t tell what the problem is. There is no BY in my code. Error and code below.

Server Side Exception

Error accessing the database: An expression of non-boolean type specified in a context where a condition is expected, near ')'.
Incorrect syntax near the keyword 'BY'.

Exception caught in: Epicor.ServiceModel

Error Detail 
============
Description:  Error accessing the database: An expression of non-boolean type specified in a context where a condition is expected, near ')'.
Incorrect syntax near the keyword 'BY'.
Program:  System.Data.dll
Method:  OnError
Original Exception Type:  SqlException
SQL Line Number:  8
SQL Error Number:  4145
Framework Method:  <InnerGetRows>b__0
Framework Line Number:  267
Framework Column Number:  36
Framework Source:  <InnerGetRows>b__0 at offset 1365 in file:line:column C:\_Releases\ICE\ICE3.2.100.9\Source\Framework\Epicor.Ice\Services\TablesetBound.cs:267:36

Server Trace Stack:     at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at System.Data.SqlClient.SqlDataReader.TrySetMetaData(_SqlMetaDataSet metaData, Boolean moreInfo)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
   at System.Data.SqlClient.SqlDataReader.get_MetaData()
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader()
   at Ice.TablesetBound`3.<>c__DisplayClass84_0.<InnerGetRows>b__0() in C:\_Releases\ICE\ICE3.2.100.9\Source\Framework\Epicor.Ice\Services\TablesetBound.cs:line 267



Client Stack Trace 
==================
   at Epicor.ServiceModel.Channels.ImplBase`1.ShouldRethrowNonRetryableException(Exception ex, DataSet[] dataSets)
   at Ice.Proxy.BO.UD10Impl.Update(UD10DataSet ds)
   at Ice.Adapters.UD10Adapter.OnUpdate()
   at Ice.Lib.Framework.EpiBaseAdapter.Update()
   at Ice.UI.App.UD10Entry.Transaction.AdapterUpdate()
   at Ice.UI.Shared.UDSupport.UDSingleViewTransaction.Update()

Inner Exception 
===============
An expression of non-boolean type specified in a context where a condition is expected, near ')'.
Incorrect syntax near the keyword 'BY'.
var UD10row = ttUD10.FirstOrDefault();

//get part table
Erp.Tables.Part partTable;


  string company = UD10row.Company;
  string partNum = UD10row.Character01;
  string oldLotNum = UD10row.Character02;
  decimal pullQty = UD10row.Number06;
  string newLotNum = callContextBpmData.Character01;
  string whse = UD10row.ShortChar01;
  string bin = UD10row.ShortChar02;

//link ttUD10 and Part tables

partTable = (from Part_row in Db.Part 
             where Part_row.Company == Session.CompanyID
             && Part_row.PartNum == partNum
             select Part_row).FirstOrDefault();

  
  // check in PartLot table that the new lot number doesn't already exist
  //var newLot = (from nl in Db.PartLot where nl.Company == company && nl.PartNum == partNum && nl.LotNum == newLotNum select nl).FirstOrDefault();
  //if (newLot == null)
    {
    //Remove qty from old lot number
    
    //choose which services to get
    using (var whseSvc = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.WhseBinSvcContract>(Db))
    
    using (var lotSvc = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.LotSelectUpdateSvcContract>(Db))

    using (var qtyAdjSvc = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.InventoryQtyAdjSvcContract>(Db))
          
    using (var partSvc = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.PartSvcContract>(Db))

    {
      //Create new tableset for services
      Erp.Tablesets.WhseBinTableset whseBinData = new Erp.Tablesets.WhseBinTableset();
      
      Erp.Tablesets.LotSelectUpdateTableset newLotData = new Erp.Tablesets.LotSelectUpdateTableset();
   
      Erp.Tablesets.InventoryQtyAdjTableset qtyAdjData = new Erp.Tablesets.InventoryQtyAdjTableset();
     
      //call bos
      bool bool1 = false;
      whseSvc.GetRows(whse, bin, 0, 0, out bool1);
      
      //call bo      
      lotSvc.GetByID(partNum, oldLotNum);     
       
      string PCID = "";
      string out1;
      string out2;
      
      //call bo       
      qtyAdjSvc.NegativeInventoryTest(partNum, whse, bin, oldLotNum, PCID, partTable.IUM, 1, 0, out out1, out out2);
       
      bool boolean = false;
      //call bo
      qtyAdjSvc.PreSetInventoryQtyAdj(ref qtyAdjData, out boolean);
      // set fields
       qtyAdjData.InventoryQtyAdj[0].AdjustQuantity = (0 - pullQty);
       qtyAdjData.InventoryQtyAdj[0].ReasonCode = "INVA";
       qtyAdjData.InventoryQtyAdj[0].LotNum = oldLotNum;
       qtyAdjData.InventoryQtyAdj[0].Reference = "Lot Split";
      
      string string1 = "";     
      lotSvc.ChkForNeedsLotAttrs(partNum, oldLotNum, string1, out bool1);
      
      string out3;
      qtyAdjSvc.SetInventoryQtyAdj(ref qtyAdjData, out out3);
      
      qtyAdjSvc.GetInventoryQtyAdj(partNum, partTable.IUM);

      partSvc.PartExists(partNum);
      
      bool bool2 = false;
      partSvc.GetList(partNum, 0, 0, out bool2);
      
      string out4;
      qtyAdjSvc.GetInventoryQtyAdjBrw(partNum, whse, out out4);
      
      bool bool3 = false;
      qtyAdjSvc.CheckSN(partNum, whse, out bool3);
      
    }}

I think I have found the problem but don’t know how to fix it. On the warehouse get row step it reads to me that the first parameter is the warehouse AND bin then there’s string, int, int, out bool. I can’t figure out how to put both pieces of information in one parameter.

<tracePacket>
  <businessObject>Erp.Proxy.BO.WhseBinImpl</businessObject>
  <methodName>GetRows</methodName>
  <appServerUri>net.tcp://chs01-test/CHS01-TEST-E10/</appServerUri>
  <returnType>Erp.Tablesets.WhseBinTableset</returnType>
  <localTime>4/24/2024 10:10:32:6225630 AM</localTime>
  <threadID>1</threadID>
  <executionTime total="43" roundTrip="19" channel="8" bpm="0" other="16" />
  <retries>0</retries>
  <parameters>
    <parameter name="whereClauseWhseBin" type="System.String"><![CDATA[WareHouseCode='FREZ' AND BinNum='PKIT']]></parameter>
    <parameter name="whereClauseWhseBinAttch" type="System.String"><![CDATA[]]></parameter>
    <parameter name="pageSize" type="System.Int32"><![CDATA[0]]></parameter>
    <parameter name="absolutePage" type="System.Int32"><![CDATA[0]]></parameter>
    <parameter name="morePages" type="System.Boolean"><![CDATA[False]]></parameter>
    <parameter name="CallContext" type="Ice.Bpm.Context.ContextDataSet">
      <ContextDataSet xmlns="http://www.epicor.com/Ice/300/Bpm/Context">
        <BpmData>
          <SysRowID>00000000-0000-0000-0000-000000000000</SysRowID>
        </BpmData>
      </ContextDataSet>
    </parameter>
  </parameters>
</tracePacket>