SAP ABAP:如何获取select某个条件下的条目数
Posted SAP蛋妞 Daniel
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SAP ABAP:如何获取select某个条件下的条目数相关的知识,希望对你有一定的参考价值。
在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某个条件下的条目数的主要内容,如果未能解决你的问题,请参考以下文章
SAP ABAP 里使用select 筛选条件里 在另一个表里查找结果为真或假的怎么写? 不好意思,没啥分。
请教一个abap事件AT SELECTION-SCREEN的问题。。
SAP ABAP select 语句为啥取不到数据(确认后台表中有数据)