2014 Feb 04 11:02 AM
Hi All,
In my report there is a query which might return more than 2000 records and in that case the req is like.
If the select query returns > 2000 records..
message 'Please execute in background' type 'E'.
else
it should display in ALV.
Now there might be a situation where this query return 50K records , in that case I have to wait for the select query to
execute completely and then display this message. I don't want that.
I want to display the message as soon as the fetched records exceeds 2000 and stop processing any further.
How can we do this??
Regards,
Faiz
Hi All,
In my report there is a query which might return more than 2000 records and in that case the req is like.
If the select query returns > 2000 records..
message 'Please execute in background' type 'E'.
else
it should display in ALV.
Now there might be a situation where this query return 50K records , in that case I have to wait for the select query to
execute completely and then display this message. I don't want that.
I want to display the message as soon as the fetched records exceeds 2000 and stop processing any further.
How can we do this??
Regards,
Faiz
2014 Feb 04 11:38 AM
Hi,
Use the packet size concept! check the packet size of 1000 each time!
So whenever it is more than 2000 exit the select and raise the error
SELECT * FROM ztablw INTO appending TABLE tab_int
PACKAGE SIZE 1000.
describe the lines
if more than 2000
set flag
exit.
endif.
ENDSELECT.
if flag = 'X'.
raise message
endif.
2014 Feb 04 11:40 AM
Maybe something like a "SELECT count(*) ... UP TO 2001 ROWS ...", and if sy-dbcnt is 2001, you issue the message and stop.+
If you don't want this extra select statement, also try with the PACKAGE SIZE addition. You can read packages of 2000 into your internal table for ALV display, and if the second package still returns sy-subrc = 0, you can stop there and display what you have so far.
In any case you should have WHERE-conditions that make use of available indexes.
Thomas
2014 Feb 04 10:36 PM
Hello faizur,
Please try implementing the below code per your requirement.
TABLES: bseg.
DATA : lt_bseg TYPE STANDARD TABLE OF bseg,
lv_cursor TYPE cursor,
lv_pack_size(5) TYPE c VALUE '2000',
lv_lines TYPE i,
lv_count TYPE i.
OPEN CURSOR lv_cursor FOR SELECT *
FROM bseg
WHERE bukrs = 'XXXX' AND
belnr = 'XXXXXXXXXX' AND
gjahr = 'XXXX'.
WHILE NOT lv_cursor IS INITIAL.
IF NOT lv_cursor IS INITIAL.
FETCH NEXT CURSOR lv_cursor INTO TABLE lt_bseg PACKAGE SIZE lv_pack_size.
IF sy-subrc EQ 0.
DESCRIBE TABLE lt_bseg LINES lv_lines.
ADD lv_lines TO lv_count.
ELSE.
CLOSE CURSOR lv_cursor.
ENDIF.
IF lv_lines GT '2000'.
MESSAGE e000(XXX) WITH 'Fetch Records are more than 2000'.
ENDIF.
ENDIF.
ENDWHILE.
Thanks,
Kishor.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |