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

a block will be executed if the previous LOOP executed successfully

Former Member
0 Likes
684

Hello experts,

After a loop statement, there is a statement after LOOP. If the LOOP was executed successfully, the following statement would be executed. For example, if the loop are executed 5 times, I wanna the following statements execute 5 times correspondingly other than 6.

Thanx.

Best regards,

ts

5 REPLIES 5
Read only

kakshat
Product and Topic Expert
Product and Topic Expert
0 Likes
646

Hi T S,

Your question is not clear. Can you elaborate?

Read only

Abhijit74
Active Contributor
0 Likes
646

Hello,

You can take a counter.

Data: lv_count type i.

lv_count = 0.

loop at gt_tab into gs_tab.

*---your code*..

lv_count = lv_count + 1.

endloop.

Now

do lv_count times.

enddo.

Thanks,

Abhijit

Read only

RaymondGiuseppi
Active Contributor
0 Likes
646

Not sure to understand your question, either very basic either very complex, I remain perplexed ?

Regards,

Raymond

Read only

Former Member
0 Likes
646

Hi ,

You can use a counter for this ....

like ... :-

Loop at i_tab into wa_tab.

your code .....

If sy-subrc = 0.

Add counter to one.

Endloop.

Then do counter times another loop which you want to execute.

Hope this will help ....

Regards,

AKS

Read only

Former Member
0 Likes
646

Hi,

U can do it in 2 ways

1) Using nested  LOOP , i.e

LOOP.

code block___________

____________________

  

  LOOP.

     */your code here

  ENDLOOP.

ENDLOOP.

2)v_counter = 0.

LOOP AT ITAB into WA.

   */your code here

    v_counter  = v_counter + 1.

ENDLOOP

DO v_counter times.

*/Your code here

ENDDO.