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

count from an internal table

Former Member
0 Likes
523

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
Read only

Former Member
0 Likes
489

try this:

data: counter(2) type n.

sort itab by division.

loop at itab.

at new division.

add 1 to counter.

endat.

endloop.

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
Read only

Former Member
0 Likes
490

try this:

data: counter(2) type n.

sort itab by division.

loop at itab.

at new division.

add 1 to counter.

endat.

endloop.

Read only

Former Member
0 Likes
489

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.