我有以下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
编译器抱怨:
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.
我理解LIKE语句的作用,例如:
@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%'
搜索所有以a开头的kunnr。但我的问题是,如何将它与输入参数p_payer
结合起来,最后它应该是LIKE %p_payer
,其中p_payer
将通过我传递的值替换。
有什么不对?
答案 0 :(得分:0)
您可以将输入参数和'%'组合在一起。 SQLScript for HANA数据库中的以下通配符
declare p varchar(10);
P = 'D';
select * from "A00077387"."ORGANIZATION" where unit like (:p || '%');
你知道,你可以使用" ||"连接'%'你的参数
您需要修改WHERE子句,如下所示
knvp.kunnr like ($parameters.p_payer || '%')
我希望它有所帮助,
答案 1 :(得分:0)
您可以将ABAP中的类似声明推回去。
BackupWebConfigFile
从此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) // you can remove this also.
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%' remove the kunnr where statement here.
我认为这看起来有点蹩脚。但这是一个解决方案:)