‎2009 Mar 12 11:35 AM
Dear All,
I have one internal table with 10000 records . I want to read a specific record with certain WHERE clause with logical operators.
Now my requirement is that as soon as that condition is satisfied , control should go to next line after Endloop BUT NOT to the next loop pass so that it will not read remaining entries.
Suggestions are most welcome.
Thanks...........
‎2009 Mar 12 11:36 AM
‎2009 Mar 12 11:37 AM
‎2009 Mar 12 11:37 AM
Try this..
Loop at itab.
if <Condition>.
EXIT.
endif.
Endloop.
‎2009 Mar 12 11:37 AM
‎2009 Mar 12 11:38 AM
Hi,
Using EXIT we can come out of the loop.
By using CONTINUE we can come out of the current iteration.
Regards,
Surya kiran
‎2009 Mar 12 11:39 AM
hi;
there are 2 ways
like
1.
loop where condition
endloop.
2.
loop
if condition
exit.
endif.
endloop.
Regards
Shashi
‎2009 Mar 12 11:41 AM
Hi,
Use exit command.
Loop at itab into wa.
if wa-field = 'CONDITION'.
EXIT.
endif.
endloop.
Cheers,
Rudhir
‎2009 Mar 12 11:42 AM
If you are looking to read specific record why do you require LOOP .. WHERE .
Please use READ TABLE WITH KEY... which will read only required record and you are process further processing.
This will improve performance over LOOP ...
Edited by: Sunil Sawaikar on Mar 12, 2009 12:42 PM
‎2009 Mar 12 11:46 AM
Hi,
Data is huge so make use off field symbol. Follow the below logic.
Field-symbol : <fs_wa_tab> type wa_tab.
Loop at i_tab assigning <fs_wa_tab>.
if (condition)
..........................
..........................
exit.
endif.
endloop.
Thanks,
Asit Purbey.
‎2009 Mar 12 11:49 AM
‎2009 Mar 12 11:57 AM
hi after select stmt write this.
select * _______
if sy-dbcnt eq 0.
do this.
else.
go to next line code here.
endif.
‎2009 Mar 12 12:02 PM
Hi,
if the conditions gives you a single record or you want to exit the loop as soon as atleast one record is read then make use of read statement instead of loop...endloop.
read table <tabname> into <workarea> with key <conditions>.
if sy-subrc = 0. " means the record is found... write the steps you have written after endloop if its found...
endif.if the conditions gives you multiple records, then use loop and if you want to exit on certain condition...
then use loop....endloop.
loop at itab into wa where conditions.
if <condtition>.
exit.
endif.
endloop.Regards,
Siddarth