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 of records in the internal table

Former Member

Hello!.

I need to get records count of internal table with condition.

for example like loop works:

LOOP AT int_table WHERE row > 0.

ENDLOOP.

but I don't need to get records of table, I just need to count it.

Do you know how to get it ?

1 ACCEPTED SOLUTION

Hello Paul,

     You can simply try this.

data : lv_count type i.

lv_count = lines( lt_itab ).

Thanks and Regards,

Nandan

14 REPLIES 14

SantoshKallem
Active Contributor
0 Kudos

Describe table <table name> lines <vlines>

As I understand DESCRIBE TABLE operator count lines of all table,

and I need to count just number of records with WHERE condition.

former_member156446
Active Contributor

Hi there..

int_table_1[] = int_table[].

delete int_table_1 where row > 1.

describe table int_table_1 lines lv_lines.
refresh int_table_1[].

0 Kudos

Hi J@Y.

I have an internal table with large number records..

creation of new table, copying of contents and then deletion of unnecessary records is very complicated, do you know much simpler way to do that ?

0 Kudos

data: int_table_1 type standard table of int_table. "<< this is easy

int_table_1[] = int_table[].

hits very less on the performance.. Infact very very little.. dont bother much about this... ABAP has some limitations.. you got to over come that with performance.. ABAP 7.0 is gonna over come with all these issue..

what is the large number you are talking about..? how big is the number?

J@Y

0 Kudos

Try with sy-index.

0 Kudos

if you don't want to copy to another table

then you have to use loop with condition

otherwise while making SELECT from table itself you need to use WHERE conditon

a®s

0 Kudos

>> what is the large number you are talking about..? how big is the number?

I meant many records in the table

thank you for your answer, I thought it is not less on the performance )).

So I will use your advise.

0 Kudos

you can try this as well:

DATA : count TYPE i.

LOOP AT itab WHERE condition TRANSPORTING NO FIELDS.
count = count + 1.
ENDLOOP.

0 Kudos

Thanks

I355602
Advisor
Advisor

Hi Paul,

To count number of records based upon any condition, use code:-


DATA : lines_count TYPE i. "for counting number of lines
 
LOOP AT itab WHERE condition TRANSPORTING NO FIELDS. "this will not move any records into work area
  lines_count = lines_count + 1. "increment counter
ENDLOOP.

WRITE : / 'Lines :', lines_count. "print

Hope this solves your problem.

Thanks & Regards

Tarun Gambhir

Hello Paul,

     You can simply try this.

data : lv_count type i.

lv_count = lines( lt_itab ).

Thanks and Regards,

Nandan

0 Kudos

but what about the condition?