Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Get all data that match to the regex.

former_member267947
Participant
0 Kudos

Hi all

How to create a CDS that select all KUNNR from table KNA1 that Customer Number starts for example with 'A%'.

I could use LIKE in the where clause but the RHS of the condition have to be static. It should depends on the input parameter.

Is it possible to do it with CDS?

Thanks

5 REPLIES 5

horst_keller
Product and Topic Expert
Product and Topic Expert

0 Kudos

Which built-in function can I use to build the regex for where clause?

For example, String Functions can not be used in the where clause.

Thanks

Read carefully the documentation. It's not obvious for novices, so read the pages several times. You'll get to that one -> ABAP CDS - cond_expr, WHERE. Of course, there's no regular expression around, but LEFT (for instance) is equivalent to LIKE 'A%'.

0 Kudos

I tried as following:

@AbapCatalog.sqlViewName: 'ZAMPAYERINFO'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Read payer information'
define view zam_payer_info
  with parameters
    p_payer :kunnr
  as select distinct from knvp
    join                  kna1 on knvp.kunnr = kna1.kunnr
{
  key knvp.kunnr as Payer,
      kna1.name1 as Name


}
where knvp.kunnr = left (:p_payer, 10)

But it does not work at all. What am I doing wrong?

Thanks

SudarshanS
Participant

Hi, a related question,

Am looking for a HANA SPS12 CDS equivalent of SUBSTR_REGEXPR() function. Couldn't find any after searching through the help docs. Please can you suggest an alternative?

Thanks

Sudarshan

https://help.sap.com/viewer/7c78579ce9b14a669c1f3295b0d8ca16/Cloud/en-US/a2f80e8ac8904c13959c69bfc30...