tags:

views:

12661

answers:

5

How do I get the row count of an internal table? I guess that I can loop on it. But there must be a saner way.

I don't know if it makes a difference but the code should run on 4.6c version.

+2  A: 

You can use the following function:

 DESCRIBE TABLE <itab-Name> LINES <variable>

After the call, variable contains the number of rows of the internal table .

IronGoofy
Thank you very much.
Igal Serban
+2  A: 

There is also a built-in function for this task:

variable = lines( itab_name ).

Just like the "pure" ABAP syntax described by IronGoofy, the function "lines( )" writes the number of lines of table itab_name into the variable.

A: 

HOW TO GET THE NUMBER OF ROW OF ITAB AT SOME WHERE CONDITION.

Hi Omer, post this as a separate question - it will make it easier to find for the next person, and you may earn rep for your question
Esti
A: 

Hello OMER,

if I understand your question correctly, you want to know the row number during a conditional loop over an internal table. You can use the system variable sy-tabix if you work with internal tables. Please refer to the ABAP documentation if you need more information (especially the chapter on internal table processing).

Example:

LOOP AT itab INTO workarea
        WHERE tablefield = value.

     WRITE: 'This is row number ', sy-tabix.

ENDLOOP.
A: 

Hi,

I think that OMMER needs to know how to get the total number of rows of itab when a condition is evaluated:

LOOP at itab WHERE value = '1'. ... ENDLOOP.

... if itab has this values:


value | field1 | field2 | field3 |

1 | XX | yy | zz |

1 | AA | BB | CC |

1 | FF | EE | DD |

2 | XX | bb | zz |

... then the result, would be 3....

Is there in SAP a parameter that return this result???

Thanks....

Alexis Sánchez SAP Development Consultant Venezuela