标签:变量 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.
标签:变量 nbsp esc nes end desc table type HERE
原文地址:https://www.cnblogs.com/sapdaniel/p/12736635.html