05-27-2008 6:40 PM
Hi Friends...
I got this problem. Imagine I have this Internal Table.
Table1
mandt datum repid dumpid
200 26052008 Ztest2 errorA
200 26052008 Ztest1 errorA
200 26052008 Ztest1 errorA
200 26052008 Ztest2 errorA
200 26052008 Ztest2 errorA
200 26052008 Ztest2 errorA
200 26052008 Ztest1 errorB
200 26052008 Ztest1 errorA
And I Need to "consolidated" this table and generate another table like this.
Table2
mandt datum repid dumpid QTD
200 26052008 Ztest1 errorA 3
200 26052008 Ztest1 errorB 1
200 26052008 Ztest2 errorA 4
My first step was to sort the main table by repid and dumpid.
mandt datum repid dumpid
200 26052008 Ztest1 errorA
200 26052008 Ztest1 errorA
200 26052008 Ztest1 errorA
200 26052008 Ztest1 errorB
200 26052008 Ztest2 errorA
200 26052008 Ztest2 errorA
200 26052008 Ztest2 errorA
200 26052008 Ztest2 errorA
But Im having problem with the loop. (using at end of).
Data: l_count type i.
loop at table1.
at new repid.
clear l_cont.
endat.
l_count = l_count + 1.
at end of dumpid.
table2-mandt = table1-mandt.
table2-datum = table1-datum.
table2-repid = table1-repid.
table2-dumpid = table1-dumpid.
table2-qtd = l_count.
append table2.
endat.
endloop.
But my l_count always get "cleared", because always enter at "at new repid". Am i forgeting something?
05-27-2008 7:19 PM
Yeah... its working.... now my table2 have only one registry of each. But my qtd remains 1 for all.
trying
05-27-2008 6:45 PM
Hello,
Try this:
SORT table1 BY mandt datum repid dumpid.
LOOP AT table1.
MOVE-CORRESPONDING table1 TO table2.
table2-qtd = 1.
COLLECT table2.
ENDLOOP.
Regards.
05-27-2008 6:46 PM
Instead of your LOOP, use this loop with COLLECT statement.
loop at table1.
table2-mandt = table1-mandt.
table2-datum = table1-datum.
table2-repid = table1-repid.
table2-dumpid = table1-dumpid.
table2-qtd = 1.
collect table2.
clear table2.
endloop.
Regards,
Naimeh Patel
05-27-2008 6:57 PM
Trying solutions provided.
Well, I think my dificult will be because those tables are differente then one another. Table 1 have a lot of others fields I dont need at table 2.
trying
05-27-2008 7:06 PM
Still not working... Maybe It is need to declare some fields of my internal table as unique key to collect work properly?
trying
05-27-2008 7:19 PM
Yeah... its working.... now my table2 have only one registry of each. But my qtd remains 1 for all.
trying
05-27-2008 7:21 PM
05-27-2008 7:22 PM
Return to use standard table without unique key and it worked fine. -
Wow. Thank you.
rewarding