2007 Sep 03 10:51 AM
hi
i wont to do this loop just one time in program what is the best way to do that?
Regards
LOOP AT target_hours_exp ASSIGNING <target_hours_exp>.
IF <target_hours_exp>-stdaz = '0.5' .
ADD 1 TO cnt_days.
ENDIF.
ENDLOOP.
2007 Sep 03 10:52 AM
Hi
LOOP AT target_hours_exp ASSIGNING <target_hours_exp> where stdaz = '0.5' .
ADD 1 TO cnt_days.
ENDLOOP.Max
hi
i wont to do this loop just one time in program what is the best way to do that?
Regards
LOOP AT target_hours_exp ASSIGNING <target_hours_exp>.
IF <target_hours_exp>-stdaz = '0.5' .
ADD 1 TO cnt_days.
ENDIF.
ENDLOOP.
2007 Sep 03 10:52 AM
Hi
LOOP AT target_hours_exp ASSIGNING <target_hours_exp> where stdaz = '0.5' .
ADD 1 TO cnt_days.
ENDLOOP.Max
2007 Sep 03 11:04 AM
hi max
i sorry i dont explain my self well i have loop for tmp_emp_day and i wont to do the loop target_hours_exp just one time in all the big loop (tmp_emp_day)
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.
DO 1 TIMES.
LOOP AT target_hours_exp ASSIGNING <target_hours_exp> WHERE stdaz = '0.5' .
ADD 1 TO cnt_days.
ENDLOOP.
ENDDO.
<fs_emp>-miss_days = <fs_emp>-miss_days - cnt_days.
APPEND <fs_emp> TO emp_miss_days.
ENDLOOP.
Regards
2007 Sep 03 1:50 PM
Hi
Ok, so u need to do a READ TABLE statament or insert EXIT statament into the loop (it's the same):
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.
* Or you use the READ TABLE statament.....:
READ TABLE target_hours_exp ASSIGNING <target_hours_exp>
WITH KEY stdaz = '0.5' .
IF SY-SUBRC = 0.
ADD 1 TO cnt_days.
ENDIF.
*...or EXIT into the LOOP:
LOOP AT target_hours_exp ASSIGNING <target_hours_exp> WHERE stdaz = '0.5' .
ADD 1 TO cnt_days.
EXIT.
ENDLOOP.
<fs_emp>-miss_days = <fs_emp>-miss_days - cnt_days.
APPEND <fs_emp> TO emp_miss_days.
ENDLOOP.Max
2007 Sep 03 10:53 AM
Hi
LOOP AT target_hours_exp ASSIGNING <target_hours_exp>.
IF <target_hours_exp>-stdaz = '0.5' .
ADD 1 TO cnt_days.
<b>if sy-INDEX = 1.
exit.
endif.</b>
ENDIF.
ENDLOOP.
reward if useful
2007 Sep 03 10:53 AM
Hi,
LOOP AT target_hours_exp ASSIGNING <target_hours_exp>.
IF <target_hours_exp>-stdaz = '0.5' .
ADD 1 TO cnt_days.
<b>exit.</b>
ENDIF.
ENDLOOP.
thanks & regards,
Venkatesh
2007 Sep 03 10:54 AM
use:
LOOP AT target_hours_exp ASSIGNING <target_hours_exp>.
if sy-tabix = 1.
IF <target_hours_exp>-stdaz = '0.5' .
ADD 1 TO cnt_days.
ENDIF.
endif.
ENDLOOP.
plz reward points if it helps
2007 Sep 03 10:54 AM
Hi Tal,
well, you may insert an EXIT statement inside your loop:
LOOP AT target_hours_exp ASSIGNING <target_hours_exp>.
IF <target_hours_exp>-stdaz = '0.5' .
ADD 1 TO cnt_days.
ENDIF.
EXIT. "<-- insert
ENDLOOP.
(depending on your needs, you may change the EXIT statement into the IF..ENDIF)
I hope it helps. Best regards,
Alvaro
2007 Sep 03 10:55 AM
Hi,
LOOP AT target_hours_exp ASSIGNING <target_hours_exp>.
IF <target_hours_exp>-stdaz = '0.5' .
ADD 1 TO cnt_days.
ENDIF.
EXIT.
ENDLOOP.
Thanks and Best Regards,
Vikas Bittera.
2007 Sep 03 10:55 AM
Hi,
LOOP AT target_hours_exp ASSIGNING <target_hours_exp> where <target_hours_exp>-stdaz = '0.5' .
ADD 1 TO cnt_days.
EXIT.
ENDLOOP.
Instead of looping you can use READ statement
READ TABLE target_hours_exp ASSIGNING <target_hours_exp> with key <target_hours_exp>-stdaz = '0.5' .
If sy-subrc = 0.
ADD 1 TO cnt_days.
endif.
rewards if useful,
regards,
nazeer
2007 Sep 03 11:03 AM
LOOP AT target_hours_exp ASSIGNING <target_hours_exp>.
IF <target_hours_exp>-stdaz = '0.5' .
ADD 1 TO cnt_days.
ENDIF.
exit.
ENDLOOP.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |