‎2007 Feb 01 3:25 PM
Hallow I have a internal table with employee number and number of hours that employee done in jobs the problem is that I have for one employee 3 kind of hour.
Pernr hour
123 10
123 10.5
123 15
456 4
456 9
How can I do that I sum the hour ex.
Emp num 123 35.5
Emp num 456 13
Because its internal table I cant do a select count
thankes
‎2007 Feb 01 3:27 PM
try control break event like......
at end of pernr.
sum.
endat.
regds,
kiran
‎2007 Feb 01 3:29 PM
Or use a <b>collect</b> statement !
( collect instead of append, it'll do the job )
Hope this helps,
Erwan
‎2007 Feb 01 3:30 PM
Hi,
COLLECT statement will give u the desired output.
regards,
madhumitha
‎2007 Feb 01 3:38 PM
Hi Antonio,
Please try this by creating new internal table (ITAB2) with the same structure (ITAB).
...
SORT ITAB.
LOOP ITAB.
ITAB2-PERNR = ITAB-PERNR.
ITAB2-HOUR = ITAB-HOUR.
COLLECT ITAB2.
ENDLOOP.
...Now, your ITAB2 has the total hours by PERNR.
Regards,
Ferry Lianto
‎2007 Feb 01 3:40 PM
Hi Antonio,
Use control-break statements to achieve your requirement.
DATA:
BEGIN OF ITAB OCCURS 0,
PERNR TYPE PERNR.
HOUR TYPE I,
END OF ITAB.
DATA ITAB_NEW TYPE ITAB OCCURS 0 WITH HEADER LINE.
DATA V_COUNT TYPE I.
DATA V_PERNR TYPE PERNR.
SORT ITAB BY PERNR.
LOOP AT ITAB.
V_PERNR = ITAB-PERNR.
AT NEW PERNR.
CLEAR V_COUNT.
ENDAT.
V_COUNT = V_COUNT + ITAB-HOUR.
AT END OF PERNR.
ITAB_NEW-PERNR = V_PERNR.
ITAB_NEW-HOUR = V_C0UNT.
APPEND ITAB_NEW.
ENDAT.
ENDLOOP.
Thanks,
Vinay