Application Development and Automation 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: 
Read only

New Open SQL Syntax CDS - Like & Parameter

0 Likes
2,413

Hi,

I am looking to create a CDS with parameters and perform a like operation on the parameter. But I can't get the correct syntax. Any help would be appreciated.

@AbapCatalog.sqlViewName: 'zviewshipnum'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Get shipment numbers like the parameter'
define view zcds_view_shipment_num
    with parameters p_shipNum : abap.Lang,
    p_haulier : TSPID
as select from /SCMTMS/D_TORROT {
    TOR_ID
}
where TOR_ID like CONCAT('%', '%')
2 REPLIES 2
Read only

UweFetzer_se38
Active Contributor
0 Likes
1,397

Looks like this is not possible. The error message and documentation say "Comparison value of LIKE condition must be a character-type literal". No variables/functions can be used here.

So you have to use the LIKE in the where statement of the calling select.

SELECT tor_id FROM zcds_view_shipment_num
INTO TABLE @DATA(tor_ids) WHERE tor_id LIKE 'Whatever%'
Read only

DoanManhQuynh
Active Contributor
0 Likes
1,397

maybe you could try instr( tor_id, :parameter ) function instead (i think it for abap 7.50+).