2008 Mar 17 4:16 PM
hi,
in my fm i choose 2 dates (between) and orgeh and i get
table with employee number and orgeh and date that he work in
month
i choose begda 012007
endda 072007
i get
e.g.
itab
employee orgeh period work_days
1234 5555 012007 22
1234 5555 022007 20
1234 5555 042007 10
1234 5555 052007 12
1234 5555 062007 9
4567 5555 012007 10
4567 5555 022007 10
4567 5555 032007 10
4567 5555 052007 10
4567 5555 062007 10as u see employee 1234 don't work in month 032007
and employee 4567 dont work in month 042007
but i wont to add to table lines with 0 like:
i wont :
employee orgeh period work_days
1234 5555 012007 22
1234 5555 022007 20
1234 5555 032007 0<--add this line
1234 5555 042007 10
1234 5555 052007 12
1234 5555 062007 9
4567 5555 012007 10
4567 5555 022007 10
4567 5555 032007 10
4567 5555 042007 0<--add this line
4567 5555 052007 10
4567 5555 062007 10what is the best way to do it?
Regards
hi,
in my fm i choose 2 dates (between) and orgeh and i get
table with employee number and orgeh and date that he work in
month
i choose begda 012007
endda 072007
i get
e.g.
itab
employee orgeh period work_days
1234 5555 012007 22
1234 5555 022007 20
1234 5555 042007 10
1234 5555 052007 12
1234 5555 062007 9
4567 5555 012007 10
4567 5555 022007 10
4567 5555 032007 10
4567 5555 052007 10
4567 5555 062007 10as u see employee 1234 don't work in month 032007
and employee 4567 dont work in month 042007
but i wont to add to table lines with 0 like:
i wont :
employee orgeh period work_days
1234 5555 012007 22
1234 5555 022007 20
1234 5555 032007 0<--add this line
1234 5555 042007 10
1234 5555 052007 12
1234 5555 062007 9
4567 5555 012007 10
4567 5555 022007 10
4567 5555 032007 10
4567 5555 042007 0<--add this line
4567 5555 052007 10
4567 5555 062007 10what is the best way to do it?
Regards
2008 Mar 17 4:38 PM
2008 Mar 17 4:57 PM
Something like that
sort itab by employee orgeh period.
itab1[] = itab[].
loop at itab.
at new of employee.
move 'Y' to v_flg.
endat.
at end of employee.
move 'Y' to v_flg1.
endat.
if v_flg eq 'Y'.
move itab-period to v_startperiod.
endif.
if v_flg1 eq 'Y'.
move itab-period to v_endperiod.
do.
read table itab1 with key employee = itab-employee
orgeh = itab-orgeh
period = v_startperiod.
if sy-subrc ne 0.
move-corresponding itab to itab2.
move v_startperiod to itab2-period,
append itab2.
endif.
v_month = v_startperiod+0(2).
v_month = v_month + 1.
v_year = v_startperiod+2(4).
if v_month = 13.
v_month = 01.
v_year = v_year + 1.
endif.
concatenate v_month v_year to v_startperiod.
if v_startperiod = v_endperiod.
exit.
endif.
enddo.
clear v_flg, v_flg1, v_startperiod, v_endperiod, v_month, v_year.
endif.
endloop.
append lines of itab2 to itab.
a®
2008 Mar 17 4:53 PM
Here's one way
DATA:
BEGIN OF tab_rec,
emp(4),
ogreh(4),
period(6),
wk_days(4) TYPE n,
END OF tab_rec,
itab LIKE STANDARD TABLE OF tab_rec.
START-OF-SELECTION.
PERFORM add_zero_rec.
*&---------------------------------------------------------------------*
*& Form add_zero_rec
*&---------------------------------------------------------------------*
FORM add_zero_rec.
CLEAR tab_rec.
tab_rec-emp = '1234'.
tab_rec-ogreh = '5555'.
tab_rec-period = '032007'.
tab_rec-wk_days = 0.
APPEND tab_rec TO itab.
SORT itab ASCENDING BY emp period+2(4) period+0(2).
ENDFORM. " add_zero_rec
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |