将数据库字段放在 WHERE 条件下的 RHS 中?
Put database field in the RHS on the WHERE condition?
下面的怎么写WHERE
?
SELECT * FROM acdoca
WHERE koart = @(COND #( blart = 'DY' THEN 'D' ELSE 'S' ) )
无法识别字段名称 BLART。怎样才能通过呢?
谢谢
埃利亚斯
编辑:这里是整个 WHERE:
WHERE acdoca~rldnr = '0L' AND
acdoca~rbukrs = @company_code AND
acdoca~belnr IN @document_no_range AND
acdoca~gjahr = @year AND
acdoca~koart = @(COND #( blart = 'DY' THEN 'D' ELSE 'S' ) )
A Host Expression @( ... )
仅在 ABAP 端解释,与数据库服务器绝对没有交互,计算表达式并在发送前用结果更新 SQL 语句到数据库。
如果我很了解你想要实现的目标,这应该可行:
SELECT * FROM acdoca
WHERE ( blart = 'DY' and koart = 'D' )
OR ( blart <> 'DY' and koart = 'S' )
INTO TABLE @DATA(itab).
注意:如果我不太理解并且您真的想要一个宿主表达式,那么有效的语法应该是这样的:
DATA blart TYPE acdoca-blart.
SELECT * FROM acdoca
WHERE koart = @( COND #( WHEN blart = 'DY' THEN 'D' ELSE 'S' ) )
INTO TABLE @DATA(itab).
编辑:这是对问题编辑的补充,整个正确的 WHERE 应该是:
WHERE acdoca~rldnr = '0L' AND
acdoca~rbukrs = @company_code AND
acdoca~belnr IN @document_no_range AND
acdoca~gjahr = @year AND
( ( acdoca~blart <> 'DY' AND acdoca~koart = 'S' ) OR
( acdoca~blart = 'DY' AND acdoca~koart = 'D' ) )
下面的怎么写WHERE
?
SELECT * FROM acdoca
WHERE koart = @(COND #( blart = 'DY' THEN 'D' ELSE 'S' ) )
无法识别字段名称 BLART。怎样才能通过呢?
谢谢
埃利亚斯
编辑:这里是整个 WHERE:
WHERE acdoca~rldnr = '0L' AND
acdoca~rbukrs = @company_code AND
acdoca~belnr IN @document_no_range AND
acdoca~gjahr = @year AND
acdoca~koart = @(COND #( blart = 'DY' THEN 'D' ELSE 'S' ) )
A Host Expression @( ... )
仅在 ABAP 端解释,与数据库服务器绝对没有交互,计算表达式并在发送前用结果更新 SQL 语句到数据库。
如果我很了解你想要实现的目标,这应该可行:
SELECT * FROM acdoca
WHERE ( blart = 'DY' and koart = 'D' )
OR ( blart <> 'DY' and koart = 'S' )
INTO TABLE @DATA(itab).
注意:如果我不太理解并且您真的想要一个宿主表达式,那么有效的语法应该是这样的:
DATA blart TYPE acdoca-blart.
SELECT * FROM acdoca
WHERE koart = @( COND #( WHEN blart = 'DY' THEN 'D' ELSE 'S' ) )
INTO TABLE @DATA(itab).
编辑:这是对问题编辑的补充,整个正确的 WHERE 应该是:
WHERE acdoca~rldnr = '0L' AND
acdoca~rbukrs = @company_code AND
acdoca~belnr IN @document_no_range AND
acdoca~gjahr = @year AND
( ( acdoca~blart <> 'DY' AND acdoca~koart = 'S' ) OR
( acdoca~blart = 'DY' AND acdoca~koart = 'D' ) )