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

doing loop just one time

Former Member
0 Likes
4,315

hi max

i have loop for tmp_emp_day and i wont to do the loop target_hours_exp just one time (fill cnt_days just one time) in all the big loop (tmp_emp_day) how i do that?

LOOP AT tmp_emp_day ASSIGNING <fs_emp>.

CALL FUNCTION 'Z_EMP_CAP'

EXPORTING

pernr = <fs_emp>-pernr

begda = fir_day

endda = last_day

IMPORTING

target_hrs = target_hrs

TABLES

target_hours_exp = target_hours_exp

work_hours = work_hours.

<b>LOOP AT target_hours_exp ASSIGNING <target_hours_exp> WHERE stdaz = '0.5' .

ADD 1 TO cnt_days.

ENDLOOP.</b>

<fs_emp>-miss_days = <fs_emp>-miss_days - cnt_days.

APPEND <fs_emp> TO emp_miss_days.

ENDLOOP.

Regards

1 ACCEPTED SOLUTION
Read only

former_member188827
Active Contributor
0 Likes
1,694

try

LOOP AT tmp_emp_day ASSIGNING <fs_emp>.

CALL FUNCTION 'Z_EMP_CAP'

EXPORTING

pernr = <fs_emp>-pernr

begda = fir_day

endda = last_day

IMPORTING

target_hrs = target_hrs

TABLES

target_hours_exp = target_hours_exp

work_hours = work_hours.

if sy-tabix = 1.

LOOP AT target_hours_exp ASSIGNING <target_hours_exp> WHERE stdaz = '0.5' .

ADD 1 TO cnt_days.

ENDLOOP.

endif.

plz reward points if it helps

4 REPLIES 4
Read only

Former Member
0 Likes
1,694

put an EXIT command in between

loop...

ur code..

EXIT.

ENDLOOP.

Read only

Former Member
0 Likes
1,694

Hi,

Use your loop inside these statements

LOOP AT...

IF sy-index EQ 1.

LOOP AT..

ENDLOOP. The inner loop that u want to execute once

ENDIF.

ENDLOOP.

Thanks and Best Regards,

Vikas Bittera.

Read only

former_member188827
Active Contributor
0 Likes
1,695

try

LOOP AT tmp_emp_day ASSIGNING <fs_emp>.

CALL FUNCTION 'Z_EMP_CAP'

EXPORTING

pernr = <fs_emp>-pernr

begda = fir_day

endda = last_day

IMPORTING

target_hrs = target_hrs

TABLES

target_hours_exp = target_hours_exp

work_hours = work_hours.

if sy-tabix = 1.

LOOP AT target_hours_exp ASSIGNING <target_hours_exp> WHERE stdaz = '0.5' .

ADD 1 TO cnt_days.

ENDLOOP.

endif.

plz reward points if it helps

Read only

Former Member
0 Likes
1,694

Hello Tal,

Use this logic.

loop at itab.

if sy-tabix = 1.

"your statements which has to execute only one time.

else.

exit.

endif.

endloop.

Reward If Useful

-


Sasi.