Hello Junaid,
you will have to raise the exception "NO_MORE_DATA" ( see the commented ABAP coding at the last 10 lines of your post ) if no more data is avaiable.
If not, the SAP BW will request until this exception will occur. ( Meaning never in your case ).
The RSA3 is quite different in this part, because there, you usually limit the resulting rows.
Kind regards,
Hendrik