OPEN CURSOR
After the OPEN CURSOR statement, the database cursor is positioned in front of the first line of the result set.
FETCH
This statement extracts the requested rows (using the addition INTO or APPENDING) from the results set of the database cursor from the current cursor position and assigns these rows to the data objects specified in the results set. If an internal table is specified after INTO or APPENDING, then either all rows are extracted, or as many as specified in the addition PACKAGE> 我写了一个很简单的report 验证:
Source code:
OPEN CURSOR lv_cursor FOR SELECT product_guid FROM comm_product.
FETCH NEXT CURSOR lv_cursor INTO TABLE lt_selection PACKAGE>
OPEN CURSOR lv_cursor FOR SELECT product_guid FROM comm_product
WHERE product_id LIKE 'JERRY06152012%'.
第一次执行size = 1
Recs变成3了,因为匹配OPEN CURSOR条件的确实只有3条记录
Size = 100, ST05结果和size = 1完全一致,都是3.
结论
WebClient UI上的Maximum Number of Results(简称Max hit)不能控制每次OPEN CURSOR去DB查找记录的条数,这个条数是由OPEN CURSOR后面跟的WHERE CONDITION决定的。Max hit只能控制OPEN CURSOR的WHERE CONDITION 所决定出的结果集里,到底有多少条返回给ABAP。
Through the verification above, this understanding is wrong.
OPEN SQL的select还有一个功能是UP TO XX ROWS.
用下面的代码测试:
SELECT product_guid INTO CORRESPONDING FIELDS OF TABLE lt_line FROM comm_product UP TO num ROWS.
Num = 1
Num = 143
说明SELECT UP TO XX ROWS是可以控制数据库表里到底有多少条记录被处理的。
但SELECT UP TO XX ROWS不能像OPEN CURSOR那样能够在WHILE循环里面反复执行,它不具备像OPEN CURSOR那样的机制,使得其能够记住当前正在操作的记录在结果集里的位置。
要获取更多Jerry的原创技术文章,请关注公众号"汪子熙"或者扫描下面二维码: