‎2008 Oct 29 8:40 AM
Hi all
I want to write a do while loop, where the condition for while will be end of internal table.
how can I wrtie this..any idea
‎2008 Oct 29 8:42 AM
Find the number of entries in the table using the describe statment and do ...enddo for as many entries in itab.
describe table itab lines l_lines.
do l_lines times.
enddo.
regards,
Advait
‎2008 Oct 29 8:46 AM
Hi
the internal table size will vary . I want to write something like this.
do
while (end of internal table)
‎2008 Oct 29 8:56 AM
Hi C,
Since the internal table size may vary, you can use the
DESCRIBE
statement....This will give the current size of the internal table.
Once you capture the size, then you can use the below given code..
DO...While sy-tabix <= v_indexHere v_index will hold the maximum lines in the internal table....so this loop will be executed until the end of the internal table.
Best Regards,
Ram.
‎2008 Oct 29 10:40 AM
the internal table size will vary . I want to write something like this.
That is the reason i recommended you to use the describe statement so that you get the number of lines in the internal table at runtime in a variable.
Anyways, I don't know why you want to do this. As Matt explained LOOP AT ... ENDLOOP should also be sufficient.
regards,
Advait
‎2008 Oct 29 8:44 AM
Hi,
You can DESCRIBE the internal table and find out the number of records in the internal table.
The you can use that number as your index in the do while statement.
DO... WHILE SY-TABIX <= TableIndex.
Best Regards,
Ram.
‎2008 Oct 29 8:47 AM
Hi,
Find the number or records in the table using describe statement.
describe table itab lines lin.
do lin times.
write your code....
enddo.
‎2008 Oct 29 8:55 AM
‎2008 Oct 29 10:57 AM
>
> Doesn't LOOP AT... ENDLOOP. exactly meet your needs????
Exactly, from what I can judge from reading the first post. I do not understand why anyone would want to make work for themselves by avoiding the simple solution and making things more complicated.
‎2008 Oct 29 9:00 AM
Hi,
First count the number of lines in internal tables using
describe table it_table lines lv_value.
now the variable lv_value will holds the number of lines in internal table ..
Then do the required do and while conditions based in this count.
Thanks,
ThiruKumaran. R
‎2008 Oct 29 9:20 AM
Hi,
Describe table tablename lines v_line.
Data count type i value 0.
while count < v_line.
perform code_to_write.
endwhile.
Form code_to_write.
count = count + 1.
endform.
This work exactly as u want.
Thnaks & Regards
Ruchi Tiwari
‎2008 Nov 05 11:54 AM