WHERE条件下的OpenSQL语法CASE语句

时间:2018-10-04 07:06:35

标签: sap abap opensql

我想问是否可以将CASE语句直接写入WHERE子句中(我知道WHERE子句也可以通过字符串传递),例如

 SELECT * FROM db_table INTO TABLE @mt_table[]
     WHERE key1 = @l_key1
          AND key2 = @l_key2
          AND key3 = @l_key3
          AND key4 = @l_key4
          AND ( WHEN l_auth = 'A' THEN username = @sy-uname
                WHEN l_auth = 'U' THEN username = @sy-uname OR username = @space 
                END ). 

1 个答案:

答案 0 :(得分:4)

您可以在WHERE子句中使用OR运算符。

SELECT * FROM db_table INTO TABLE @mt_table[]
 WHERE key1 = @l_key1
   AND key2 = @l_key2
   AND key3 = @l_key3
   AND key4 = @l_key4
   AND ( ( l_auth = 'A' AND username = @sy-uname )
      OR ( l_auth = 'U' AND ( username = @sy-uname OR username= @space ) )
       ).

在Open Sql的where子句中没有找到任何支持案例的文档。