Solved

Select statement error on where clause

  • 14 November 2023
  • 1 reply
  • 67 views

Badge

Below the query is would like to run.

It is supposed to select rows from the contactcollectiontable and exclude records based  statusecode and on multiple values in the FunctionCode column.

$where = "StatusCode = '2' and FunctionCode<>'Z14' and FunctionCode<>'Z95' and FunctionCode<>'Z96' and FunctionCode<>'Z97');" 
$A = Select-SAPHybrisC4C -Connection $conn -Table "ContactCollection" -Columns $Columns -Where $Where

However the code above is not working and throws this error:

Select-SAPHybrisC4C : [500] Could not execute the specified command: [ERROR] Error in filter System Query, Operation failed::Expression can not converted
 into ABAP select options. 
At line:2 char:6
+ $A = Select-SAPHybrisC4C -Connection $conn -Table "ContactCollection" ...
+      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (CData.SAPHybris...HybrisC4CSelect:SAPHybrisC4CSelect) [Select-SAPHybrisC4C], avx
    + FullyQualifiedErrorId : 1,CData.SAPHybrisC4CCmdlets.Commands.SAPHybrisC4CSelect

 

When i filter on StatusCode and just an single value in FunctionCode, the cmd works great.

Is there some one arround who can point me in the right direction?

icon

Best answer by Ankit Singh 27 November 2023, 15:16

View original

1 reply

Userlevel 5
Badge +1

Hi @Gijsbert 

The error message you're encountering seems to indicate an issue with the way the filter expression is being constructed and handled by the `Select-SAPHybrisC4C` command. The error message suggests that the expression cannot be converted into ABAP select options.

One way to approach this issue is to modify the query to construct the filter differently. Instead of multiple 'not equals' conditions for `FunctionCode`, you can use an `IN` clause to filter multiple values in a more concise way.

Here's an example of how you might modify your query:

$where = "StatusCode = '2' and FunctionCode NOT IN ('Z14', 'Z95', 'Z96', 'Z97');" 
$A = Select-SAPHybrisC4C -Connection $conn -Table "ContactCollection" -Columns $Columns -Where $Where

Using the `NOT IN` clause allows you to specify multiple values for `FunctionCode` in a single line, which might help avoid the issue you're facing with the conversion into ABAP select options.


If this modification still doesn't resolve the issue, you might consider reaching out to the Tech support at https://www.cdata.com/support/submit.aspx for further assistance or alternative approaches to construct your filter condition.

Additionally, ensure that the syntax and capabilities of the querying tool align with the SQL-like syntax being used in your PowerShell script.

Reply