Application Development and Automation 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: 
Read only

ABAP DOC count

Former Member
0 Likes
380

Hi

I have a internal table of the following format

Material | doc#

1000 | 1001

1000 | 1002

1000 | 1003

2000 | 2001

2000 | 2002

2000 | 2003

2000 | 2004

I want to a extend the progam to get total material doc count from that internal table

Desired format

Material | Count

1000 | 3

2000 | 4

Please let me know how to accomplish this.

1 ACCEPTED SOLUTION
Read only

Pawan_Kesari
Active Contributor
0 Likes
354

I assume first field of internal table is Material, follow this algo


sort the internal table by material.
loop on internal table.

  at new material.
   clear count.
  endat.

  count = count + 1.

 at end of material.
  write work_area-material , count.
 endat

endloop.

3 REPLIES 3
Read only

Pawan_Kesari
Active Contributor
0 Likes
356

I assume first field of internal table is Material, follow this algo


sort the internal table by material.
loop on internal table.

  at new material.
   clear count.
  endat.

  count = count + 1.

 at end of material.
  write work_area-material , count.
 endat

endloop.

Read only

0 Likes
354

thanks guys .. worked like charm

Read only

Former Member
0 Likes
354

you need to loop the internal table and then use AT NEW statement.

something like this:

data: count type I value 0.

data: begin of new_itab occurs 0,

material like matrn,

count type I,

end of new_itab.

loop at itab.

at new itab-material

clear count.

endat.

at end of itab-material.

new_itab-material = itab-material.

new_itab-count = count.

append new_itab.

endat.

endloop.