cancel
Showing results for 
Search instead for 
Did you mean: 

SAP CDS Parameter without leading zero

hassin
Explorer
0 Kudos
8,225

Hello Guys,

I have a question about the use of parameters in my CDS Code.

For example I'm want to search via parameter a specific material.

In our DB all material have leading zeros.

But I want to enter the materialnummer without the leading zero.

Down you can see my code, hava you idea/tip how I can solve this problem?

Regads

Hassin

@AbapCatalog.sqlViewName: 'ZCS_MARA_PARA'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'VDS View with Parameter'

define view ZCS_MARA_Test1_PARA
    with parameters p_matnr : matnr, p_ernam : ernam
as select from ZCP_MARAView_Test1 

{
    //ZCP_MARAView_Test1
    ltrim(matnr,'0')    as Materialnummer,
    ersda               as Angelegt_Am,
    ernam               as Angelegt_Von,
    laeda               as Geaedert_Am,
    aenam               as Geaendert_Von
}
where   matnr = :p_matnr

Accepted Solutions (1)

Accepted Solutions (1)

hassin
Explorer

To solve this issue you have to use "ltrim(matnr,'0') as Matnr_Test" one view before.

Answers (1)

Answers (1)

Cocquerel
Active Contributor
0 Kudos

Would changing the WHERE clause this way fit your requirement ?

where ltrim(matnr,'0') = :p_matnr
hassin
Explorer
0 Kudos

It would fit my requirement but I get an error.

User-defined functions are not supported in the WHERE clause

Cocquerel
Active Contributor
0 Kudos

maybe it is because of your HANA version because when running the following statement on my system that 2.0 SPS05, it is working fine.

select ltrim('000111','0') from dummy
where ltrim('000111','0') = '111'