Skip to Content
author's profile photo
Former Member

count from an internal table

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

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    author's profile photo
    Former Member
    Posted on Sep 28, 2007 at 08:11 AM

    try this:

    data: counter(2) type n.

    sort itab by division.

    loop at itab.

    at new division.

    add 1 to counter.

    endat.

    endloop.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Sep 28, 2007 at 08:20 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded