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 from an internal table

Former Member
0 Kudos

Hi

In my internal table, I have multiple entries for different divisions.

I need the count of all the distinct divisions.

For example: I have

2 records for division 20,

2 records for division 30, and

2 records for division 40.

then in this case the count value should be 3.

Can anyone suggest any logic for this.

Points will rewarded for correct answer.

Regards

1 ACCEPTED SOLUTION

Former Member
0 Kudos

try this:

data: counter(2) type n.

sort itab by division.

loop at itab.

at new division.

add 1 to counter.

endat.

endloop.

2 REPLIES 2

Former Member
0 Kudos

try this:

data: counter(2) type n.

sort itab by division.

loop at itab.

at new division.

add 1 to counter.

endat.

endloop.

Former Member
0 Kudos

Hi,

Try the follwing it will resolve the problem. Use control break for internal table (AT new field name) & counter. increase the counter at each new loop pass: e.g.:

Loop at itab into wa.

AT NEW division.

count = count + 1.

ENDAT.

Endloop.

Reward points if helpful answer.

Ashvender.