‎2007 Sep 27 10:10 AM
How to do a loop for a table to get the total count of the rows?
And write out the total number of rows.
‎2007 Sep 27 10:12 AM
Hi
i am sending you a smaple code from my program
plz see this you can understand very easyly
LV_COUNT = 0.
LOOP AT IT_OUTPUT INTO WA_OUTPUT.
LV_COUNT = LV_COUNT + 1.
WA_OUTPUT-COUNT = LV_COUNT.
APPEND WA_OUTPUT TO IT_OUTPUT_1.
ENDLOOP.
REFRESH IT_OUTPUT.
IT_OUTPUT = IT_OUTPUT_1.
output is my final internal table and output1 is also type of that output structure
<b>Reward if usefull</b>
‎2007 Sep 27 10:12 AM
loop at itab.
write:/sy-tabix.
endloop.
Message was edited by:
abapuser
‎2007 Sep 27 10:13 AM
‎2007 Sep 27 10:15 AM
Hi ,
If i understand correctly you want to get the number of rows in an internal table ,
if that is the case use the DESCRIBE command.
with the addition LINES.
Regards
Arun
‎2007 Sep 27 10:18 AM
DATA : MY_TABIX TYPE SY-TABIX.
LOOP AT ITAB.
AT LAST .
MY-TABIX = SY-TABIX.
ENDAT.
ENDLOOP.
IN MY_TABIX YOU HAVE NUMBER OF RECORDS.
REWARD IF USEFUL
AMIT SINGLA
‎2007 Sep 27 10:26 AM
describe table itab.
now it wil fil the system field SY-TFILL wid number of lines in internal table
use like this
describe table itab.
write : sy-tfill.
reward if useful
‎2007 Sep 27 10:22 AM
Instead of looping into the table you can use a direct ABAP command:
DESCRIBE TABLE itab LINES gv_record.
WRITE: gv_lines.
gv_line should be type 'i' and will give you number of records in an internal table.
PS: Please mark this question answered since this solves your query.
Regards.
‎2007 Sep 27 10:26 AM
I'm looping my database table. I want to know how many records i have in my database table.
‎2007 Sep 27 10:35 AM
How can you loop at your DB table thats not intelligent.
You can transfer them into an internal table and find the entry count.
‎2007 Sep 27 10:39 AM
use sy-dbcnt for the number of record fetched from database table
‎2007 Sep 27 10:29 AM
‎2007 Sep 27 10:31 AM
‎2007 Sep 27 10:40 AM
your need to select records which you want from your table into an internal table and then you can loop it and count the number of records.
hope this would be help ful.
cheers
AJ
‎2007 Sep 27 10:33 AM
Thanks everybody. My question is solved.
I just use SQL statement to loop my table. 😃