Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

loop

Former Member
0 Likes
660

how to loop 2 times ??

regards,

pradeep

6 REPLIES 6
Read only

Former Member
0 Likes
641

Hi Sudheer,

Can u please give futher explanation?

You can do 2 loop's sequencialy, or nested loop!


loop itab into wa_itab1.

 loop itab into wa_itab2.
 ...
 endloop.

endloop.

Is it this what you are looking for?

Regards,

Marcelo Moreira

Read only

0 Likes
641

actualli i have to read two records from table with where condition..

regards,

Read only

0 Likes
641

hi,

try to use the below logic.

sort lt_itab.

loop at lt_tab into ls_tab where <cond>

if sy-tabix GT 2.

exit.

endif.

endloop.

Read only

ferry_lianto
Active Contributor
0 Likes
641

Hi,

Please try this ...


LOOP AT ITAB INTO WA_ITAB
             FROM 1 TO 2
             WHERE <condition>.

 ...
ENDLOOP.

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
641

if it 2 loop one inside other .

LOOP AT itab1.

LOOP AT itab2 WHERE *** = Itab1-***.

ENDLOOP.

ENDLOOP.

If you want to end the loop pass after the 2nd time

IF sy-index > limit. " sy-tabix > limit.

EXIT.

ENDIF.

or use

DO [n TIMES]

ENDDO.

Read only

Former Member
0 Likes
641

Hi,

check the follow code:

DATA: rows type i.

DESCRIBE TABLE itab LINES rows.

LOOP itab from rows.

ENDLOOP.

Regards,