码迷,mamicode.com
首页 > 其他好文 > 详细

SAP ABAP:如何获取select某个条件下的条目数

时间:2020-04-20 12:05:25      阅读:351      评论:0      收藏:0      [点我收藏+]

标签:变量   nbsp   esc   nes   end   desc   table   type   HERE   

       在ABAP中,有时候我们需要取某一条件下的条目数,要如何实现呢?

       这里有程咬金的三板斧:

(1)第一板斧:系统变量sy-dbcnt

 1   DATA: L_COUNT TYPE I.
 2   SELECT EQUI~EQUNR
 3          EQKT~EQKTX
 4          ILOA~SWERK
 5     INTO TABLE GT_EQUI
 6     FROM EQUI
 7     LEFT JOIN EQKT  ON  EQUI~EQUNR = EQKT~EQUNR  AND SPRAS = SY-LANGU
 8     LEFT JOIN EQUZ  ON  EQUI~EQUNR = EQUZ~EQUNR  AND EQUZ~DATBI = 99991231
 9     INNER JOIN ILOA  ON  EQUZ~ILOAN = ILOA~ILOAN
10     WHERE ILOA~SWERK IN S_SWERK
11     AND   EQUI~ERDAT IN S_ERDAT .
12 
13   IF SY-SUBRC = 0.
14     L_COUNT = SY-DBCNT.
15   ENDIF.

(2)第二板斧:select  count (*)

 1   DATA: L_COUNT TYPE I.
 2   SELECT COUNT( * )
 3     INTO  L_COUNT
 4     FROM EQUI
 5     LEFT JOIN EQKT  ON  EQUI~EQUNR = EQKT~EQUNR  AND SPRAS = SY-LANGU
 6     LEFT JOIN EQUZ  ON  EQUI~EQUNR = EQUZ~EQUNR  AND EQUZ~DATBI = 99991231
 7     INNER JOIN ILOA  ON  EQUZ~ILOAN = ILOA~ILOAN
 8     WHERE ILOA~SWERK IN S_SWERK
 9     AND   EQUI~ERDAT IN S_ERDAT .
10 
11   IF SY-SUBRC = 0.
12 
13   ENDIF.

(3)第三板斧:select  count (*)

 1   DATA: L_COUNT TYPE I.
 2   SELECT EQUI~EQUNR
 3          EQKT~EQKTX
 4          ILOA~SWERK
 5     INTO TABLE GT_EQUI
 6     FROM EQUI
 7     LEFT JOIN EQKT  ON  EQUI~EQUNR = EQKT~EQUNR  AND SPRAS = SY-LANGU
 8     LEFT JOIN EQUZ  ON  EQUI~EQUNR = EQUZ~EQUNR  AND EQUZ~DATBI = 99991231
 9     INNER JOIN ILOA  ON  EQUZ~ILOAN = ILOA~ILOAN
10     WHERE ILOA~SWERK IN S_SWERK
11     AND   EQUI~ERDAT IN S_ERDAT .
12 
13   IF SY-SUBRC = 0.
14 *    L_COUNT = SY-DBCNT.
15     DESCRIBE TABLE GT_EQUI LINES L_COUNT.
16   ENDIF.

 

SAP ABAP:如何获取select某个条件下的条目数

标签:变量   nbsp   esc   nes   end   desc   table   type   HERE   

原文地址:https://www.cnblogs.com/sapdaniel/p/12736635.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!