Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

COUNT

Former Member
0 Kudos

DEAR All,

i am showing the output is

aa

cd

er

aa

cd

er

aa

tr . this way.

my target is

how many aa,cd,er is available.

for eg:

aa 3

cd 2

er 2.

tr 1.

plz help me

regards

raj

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

u can use AT-NEW event. explain ur problem clearly man.

abaper007.

4 REPLIES 4

Former Member
0 Kudos

Hi,

u can use AT-NEW event. explain ur problem clearly man.

abaper007.

MarcinPciak
Active Contributor
0 Kudos
TYPES: begin of t_out_table occurs 0,
          field type ... "yours aa, cd, er ...
          number type i,
        end of t_out_table.

data: out_table type t_out_table with key field with header line.

"now just use use COLLECT 
Loop at int_table. "your internal table where you store aa, cd, er
  move-corresponding int_table to out_table.   "moves just the key
  out_table-number = 1.    "now you put for each entry 1
  collect out_table.          "and collect via key field
endloop.

Former Member
0 Kudos

Hi raj,

If you're using a table. you need to sort it.

before you can use this.


loop at itab.

at new itab-field.
**
endat.

at end of itab-field.
**
endat.

endloop.

Explain clearly from where you got the data.

regards,

Kais

Former Member
0 Kudos

Hello


data: begin of counttab occurs 0,
     field1(2),
     count type i,
end of counntab.
data: counter type i.
sort itab.
loop at itab.
  at new itab-fieldname.
    counter = 0.
  endat.
  counter = counter + 1.
  at end of itab-fieldname.
    clear counttab.
    counttab-field1 = itab-fieldname.
    counttab-count = counter.
    append counttab.
  endat.
endloop.

In table counttab you will have your result.