Skip to Content
-2

how can one select data similar to SQL WHERE LIKE from a parameter value

Hi all

I have the following CDS:

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

that the compiler complains:

Comparison value of LIKE condition must be a character-type literalZAM_PAYER_INFO (Data Definition)

As you can see on the CDS code, I am using character-type.

I understand, what LIKE statement do, for example:

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

Search all kunnr that starts with a. But my problem is, how to combine it with input parameter p_payer, at the end it should be LIKE %p_payer, where p_payer will be replace through the value that I passed.

What can be wrong?

Thanks

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Jan 13 at 11:13 PM

    Please read the documentation ...

    It is as close as F1.

    Add comment
    10|10000 characters needed characters exceeded

    • Aha. It has to be like '%a' otherwise it is not possible, it can not derive from a parameter?
      How can I create a select for "Give me all customers, that the name starts with a f"?

      Thanks