2008 Jan 02 6:12 AM
Hi,
Anybody can tell me, "How do we get the number of lines in an internal table?"
2008 Jan 02 6:14 AM
Hi,
Use describe statement
describe table itab lines w_int.
in w_int will contain no. of lines.
Plzz reward points if it helps.
Hi,
Anybody can tell me, "How do we get the number of lines in an internal table?"
2008 Jan 02 6:13 AM
data : N type I.
describe table ITAB lines N. " N gives the no of records of itabRegards
Gopi
2008 Jan 02 6:14 AM
Hi,
Use describe statement
describe table itab lines w_int.
in w_int will contain no. of lines.
Plzz reward points if it helps.
2008 Jan 02 9:32 AM
Hi,
This can be done in several ways. But the latest and simple way is as follows.
DATA : BEGIN OF str_test,
n1 TYPE i,
n2 TYPE i,
END OF str_test.
DATA : itab LIKE STANDARD TABLE OF str_test WITH HEADER LINE.
DO 10 TIMES.
CLEAR str_test.
str_test-n1 = sy-index.
str_test-n2 = sy-index * 2.
APPEND str_test TO itab.
ENDDO.
IF LINES( itab ) ne 0.
LOOP AT itab.
WRITE 😕 itab-n1, itab-n2.
ENDLOOP.
ENDIF.
Simple code is : Lines(<table name>) gives number of lines in internal table.
All the very best to you.
2008 Jan 02 9:45 AM
Hi Ravi,
Just include the field SY-TABIX in your Write statement for the internal table. This should help you in achieving the no. of records.
Reward points if useful,
Regards,
Bhavin P Shah
2008 Jan 03 9:57 AM
by using sy-dbcnt we can find the total number of records in the internal table.
2008 Jan 03 11:58 AM
hi,
report zsample.
tables:mara.
data:itab like mara occurs 0 with header line.
data:v_lines type i.
select-options :s_matnr for mara-matnr.
start-of-selection.
select * from mara into table itab where matnr in s_matnr.
clear v_lines.
if sy-subrc = 0.
describe table itab lines v_lines.
write: v_lines , 'No of records in internal table for the given range'.
endif.
Regds
Sivaparvathi
Please reward points if helpful..
2008 Jan 04 6:31 AM
Hi ,
Internal table in ABAP
*An internal table is a run time instance. It get created when program starts execution.
*It get destroyed when program terminates. it has two different parts. HeaderLine(optional) & Body(Compulsory).
*Any value that comes to or goes from interanal table , that travels through headerline.\
*A related program is .
*declaration.
data: begin of inernaltable occurs 0,
x type c,
y type i,
end of itab.
*initializing headerline
internaltable-x = 'd'.
internaltable-y = 34.
*storing value into internal table
appene internaltable .
appene internaltable .
appene internaltable .
*reading internal table
loop at itab .
write: / internaltable-x, internaltable-y. "writes to output list
endloop.
Fields of Internal Tables
SY-TABIX
Current line of an internal table. SY-TABIX is set by the statements below, but only for index tables. The field is either not set or is set to 0 for hashed tables.
APPEND sets SY-TABIX to the index of the last line of the table, that is, it contains the overall number of entries in the table.
COLLECT sets SY-TABIX to the index of the existing or inserted line in the table. If the table has the type HASHED TABLE, SY-TABIX is set to 0.
LOOP AT sets SY-TABIX to the index of the current line at the beginning of each loop lass. At the end of the loop, SY-TABIX is reset to the value that it had before entering the loop. It is set to 0 if the table has the type HASHED TABLE.
READ TABLE sets SY-TABIX to the index of the table line read. If you use a binary search, and the system does not find a line, SY-TABIX contains the total number of lines, or one more than the total number of lines. SY-INDEX is undefined if a linear search fails to return an entry.
SEARCH <itab> FOR sets SY-TABIX to the index of the table line in which the search string is found.
SY-TFILL
After the statements DESCRIBE TABLE, LOOP AT, and READ TABLE, SY-TFILL contains the number of lines in the relevant internal table.
SY-TLENG
After the statements DESCRIBE TABLE, LOOP AT, and READ TABLE, SY-TLENG contains the length of the lines in the relevant internal table.
SY-TOCCU
After the statements DESCRIBE TABLE, LOOP AT, and READ TABLE, SY-TLENG contains the initial amount of memory allocated to the relevant internal table.
Reward Points if it is usefull ...
Girish
2008 Jan 04 8:27 AM
u can use a system field sy-tabix
the value of which which will give u the no of lines in the internal table
2008 Jan 04 10:27 AM
U can use the describe statement as said above
or u can run the loop and after the execution of the loop
SY-DBCNT will give the no. of times theloop is executed or the No. of lines.
Reward points if found usefull.
| User | Count |
|---|---|
| 6 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |