2011 Apr 07 10:41 PM
Hi ,
I want to select unique enteries from an internal table and count that numebr in another row
For example my internal table
ITAB
EBELN
0026000060
0026000060
0026000060
0026000060
0026000061
0026000061
0026000061
0026000062
0026000062
0026000063
I need to show in ITAB_FINAL
EBELN COUNT OF UNIQUE RECORDS
0026000060 4
0026000060 4
0026000060 4
0026000060 4
0026000061 3
0026000061 3
0026000061 3
0026000062 2
0026000062 2
0026000063 1Please help me how to achive this.
Thanks
Kiran
Hi ,
I want to select unique enteries from an internal table and count that numebr in another row
For example my internal table
ITAB
EBELN
0026000060
0026000060
0026000060
0026000060
0026000061
0026000061
0026000061
0026000062
0026000062
0026000063
I need to show in ITAB_FINAL
EBELN COUNT OF UNIQUE RECORDS
0026000060 4
0026000060 4
0026000060 4
0026000060 4
0026000061 3
0026000061 3
0026000061 3
0026000062 2
0026000062 2
0026000063 1Please help me how to achive this.
Thanks
Kiran
2011 Apr 08 1:00 AM
Hi kiran.,
refer this.,
types:begin of ty_ebeln,
ebeln type ebeln,
end of ty_ebeln.
types:begin of ty_count, " req op structure..
ebeln type ebeln,
count type i,
end of ty_count.
data:itab type table of ty_ebeln,
wa_ebeln type ty_ebeln,
it_count type table of ty_count,
wa_count type ty_count.
data index type i.
sort itab by ebeln ascending.
LOOP AT itab into wa_ebeln.
index = index + 1.
at end of ebeln.
wa_count-ebeln = wa_ebeln-ebeln.
wa_count-count = index.
append wa_count to it_count.
clear wa_count.
index = 0.
endat.
ENDLOOP.
LOOP AT it_count into wa_count.
write:/ wa_count-ebeln, 10 wa_count-count.
ENDLOOP.reply if u need some more clarifications,.
Thanks & Regards
Kiran
2011 Apr 08 1:06 AM
Hi,
I have solved my own.
..CLEAR g_ebeln.
loop at itab into wa.
IF wa-ebeln NE g_Ebeln.
LOOP AT itab where ebeln = wa-ebeln.
g_count = g_count + 1.
ENDLOOP.
ENDIF.
g_ebeln = wa-ebeln.
clear wa_final.
wa_final-ebeln = wa-ebeln.
wa_final-count = g_count.
append wa_final to itab_final.
ENDLOOP. Thanks..
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |