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 repeat the data to 3 times

Former Member
0 Likes
2,761

Hi Experts,

I am facing problem while running the code.

data : it_cus type table of vbrk,

w_cus like line of it_cus.

START-OF-SELECTION.

if z_cust is not initial.

select KUNRG

from VBRK

into corresponding fields of table it_cus

where KUNRG in z_cust .

ENDIF

delete adjacent duplicates from it_cus.

loop at it_cus into w_cus.

Z_KUNRG = w_cus-KUNRG.

  • append w_cus to btab..

perform cal_intrest.

IF Z_KUNRG =< z_cust-HIGH. " This code i have written to stop the loop.

EXIT.

ENDIF.

The program is running 3 times to retrive the data without this code.

Can you suggest any other than to stop the loop at z_cust-HIGH.

clear w_cus.

clear ITK.

clear W_ITK.

clear I_IT .

free I_IT .

clear w_it.

clear Z_DMBTR.

endloop.

Thx & Regds

Vipul

Hi Experts,

I am facing problem while running the code.

data : it_cus type table of vbrk,

w_cus like line of it_cus.

START-OF-SELECTION.

if z_cust is not initial.

select KUNRG

from VBRK

into corresponding fields of table it_cus

where KUNRG in z_cust .

ENDIF

delete adjacent duplicates from it_cus.

loop at it_cus into w_cus.

Z_KUNRG = w_cus-KUNRG.

  • append w_cus to btab..

perform cal_intrest.

IF Z_KUNRG =< z_cust-HIGH. " This code i have written to stop the loop.

EXIT.

ENDIF.

The program is running 3 times to retrive the data without this code.

Can you suggest any other than to stop the loop at z_cust-HIGH.

clear w_cus.

clear ITK.

clear W_ITK.

clear I_IT .

free I_IT .

clear w_it.

clear Z_DMBTR.

endloop.

Thx & Regds

Vipul

6 REPLIES 6
Read only

Former Member
0 Likes
1,738

Hi

loop at it_cus into w_cus

 where kunrg = zcust-high 

.

Z_KUNRG = w_cus-KUNRG.

append w_cus to btab..

perform cal_intrest.

IF Z_KUNRG =< z_cust-HIGH. " This code i have written to stop the loop.

EXIT.

ENDIF.

The program is running 3 times to retrive the data without this code.

Can you suggest any other than to stop the loop at z_cust-HIGH.

clear w_cus.

clear ITK.

clear W_ITK.

clear I_IT .

free I_IT .

clear w_it.

clear Z_DMBTR.

endloop.

Read only

Former Member
0 Likes
1,738

Hi,

try this..

loop at it_cus into w_cus where KUNRG GT Z_CUST-HIGH.

endloop.

Read only

Former Member
0 Likes
1,738

hi Vipul,

instead of using

IF Z_KUNRG =< z_cust-HIGH

Try using

IF Z_KUNRG LE z_cust-HIGH

This will help u., Pls try it out.

Thanks and regards

Suraj

Read only

Former Member
0 Likes
1,738

Hi:

Before delete adjacent duplicates from it_cus , sort the table IT_cust

Try it.

Regards

Shashi

Read only

Former Member
0 Likes
1,738

Hi Vipul,

EXIT statement is used to end the current loop process. Your approach is correct.

You can use the below code.


IF z_kunrg LE z_cust-high.

EXIT.

ENDIF.

"LE" stands for the logical statement "less than or equal to".

Read only

Former Member
0 Likes
1,738

k