计数 > 1 的 ABAP Select 个字段

ABAP Select fields with count > 1

有什么方法可以 select BSID 中 BUKRS-KUNNR-DMBTR 的组合大于 1 的某些字段。我认为下面的 select 会起作用,但它不起作用'吨。

SELECT bukrs kunnr dmbtr COUNT(*)
      INTO TABLE git_double
    FROM bsid
    WHERE bukrs = '1000' AND
          blart = 'WP'   AND
          budat IN s_budat AND
          gjahr IN s_gjahr AND
          count(*) > 1
    GROUP BY bukrs kunnr dmbtr.

有没有办法在 1 selection 中做到这一点?
谢谢

关于 aggregate functions like COUNT can be done inside the HAVING 条款的选择

  SELECT bukrs kunnr dmbtr COUNT(*)
    INTO TABLE git_double
      FROM bsid
      WHERE bukrs = '1000' AND
            blart = 'WP'   AND
            budat IN s_budat AND
            gjahr IN s_gjahr
      GROUP BY bukrs kunnr dmbtr
      HAVING COUNT(*) > 1.        " <==== HAVING after GROUP BY

参考,从ABAP 7.40 SP05开始,也可以使用host variables:

来写
  SELECT bukrs, kunnr, dmbtr, COUNT(*) AS accd_count
    INTO TABLE @DATA(git_double)
      FROM bsid
      WHERE bukrs = '1000' AND
            blart = 'WP'   AND
            budat IN @s_budat AND
            gjahr IN @s_gjahr
      GROUP BY bukrs, kunnr, dmbtr
      HAVING COUNT(*) > 1.