‎2008 Mar 26 9:50 AM
hi friends,
can u pls solve this query asap.
i have selected three fields into an internaltable which is standard type of internal table having only three fields.
those are employeeno,date,hours........
the records are like this....
ex: 1 12/03/2008 40
2 13/03/2008 50
1 12/03/2008 60.
so i want to add the fields which have same employee no as well as same date.
and i want the record like this.
12/03/2008 100
how can i? possible send the code.
the fields in the database table r not primary fields.........
‎2008 Mar 26 9:53 AM
use COLLECT statement
Edited by: Pankaj Singh on Mar 26, 2008 3:24 PM
Edited by: Pankaj Singh on Mar 26, 2008 3:24 PM
‎2008 Mar 26 10:00 AM
Hi,
first u have to sort ur internal table by emp no and date .
then on change of emp no date , u need to collect the hours and transfer it into another internal table which will be in ur req format.
i hope u get the point
reward if helpful
‎2008 Mar 26 5:52 PM
Hi Rahul,
Sort the internal table by emp no and date .
Then write on change of emp no date
use collect statement
Thanks & Regards,
AMK.
Reward Points if useful.
‎2008 Mar 27 3:58 AM
First Declare your internal table2 with the employee_no, date, hours fields and collect them into this table from your original internal table(say internal table 1).
1 12/03/2008 40
2 13/03/2008 50
1 12/03/2008 60
loop at it_table1.
move: it_table1-employee_no to it_table2-employee_no,
it_table1-date to it_table2-date,
it_table1-hours to it_table2-hours.
collect it_table2.
endloop.
you will have a records like this
1 12/03/2008 100.
2 13/03/2008 50.
Note if you dont want the employee no. just do repeat the above process but this way if you have another employee who worked on the same date will get collected
for eg:
1 12/03/2008 40
2 13/03/2008 50
1 12/03/2008 60
2 12/03/2008 70 "Assumption of this record in your internal table
loop at it_table2.
move it_table2-date to it_table3-date,
it_table2-hours to it_table3-hours.
collect it_table3.
endloop.
you will have records like this.
12/03/2008 170.
13/03/2008 50.
siddu
‎2008 Mar 29 6:43 PM
Hello you can use the following code:
SORT it_table1 BY date hours.
LOOP AT it_table1.
COLLECT it_table1 INTO it_table2.
ENDLOOP.
Regards.